Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1.  
  2. /**
  3. * Reads the start time for a call based upon a 24- hour clock and the length of the call in minutes.
  4. *
  5. * Kevin Waddles
  6. * 8/28/14
  7. */
  8. import java.util.*;
  9.  
  10. public class Telephone
  11. {
  12. public static void main(String[] args)
  13. {
  14. Scanner console = new Scanner(System.in);
  15.  
  16. int begin, end, duration, time, minutes, hours;
  17. double cost, extraCost;
  18.  
  19. System.out.print("Enter the time the call begins in 24 hour format: ");
  20. begin = console.nextInt();
  21. System.out.print("Enter the time the call ends in 24 hour format: ");
  22. end = console.nextInt();
  23.  
  24. if (begin < end)
  25. {
  26. duration = end - begin;
  27. hours = duration / 100;
  28. minutes = 100 - (duration % 100);
  29. time = (hours * 60) + minutes;
  30. }
  31. else
  32. {
  33. duration = (end + 2400) - begin;
  34. hours = duration / 100;
  35. minutes = 100 - (duration % 100);
  36. time = (hours * 60) + minutes;
  37. }
  38.  
  39. System.out.println("\nCall summary:");
  40. System.out.print("Started at " + hours + " for " + minutes + " minutes.");
  41.  
  42.  
  43. console.close();
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement