Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Reads the start time for a call based upon a 24- hour clock and the length of the call in minutes.
- *
- * Kevin Waddles
- * 8/28/14
- */
- import java.util.*;
- public class Telephone
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int begin, end, duration, time, minutes, hours;
- double cost, extraCost;
- System.out.print("Enter the time the call begins in 24 hour format: ");
- begin = console.nextInt();
- System.out.print("Enter the time the call ends in 24 hour format: ");
- end = console.nextInt();
- if (begin < end)
- {
- duration = end - begin;
- hours = duration / 100;
- minutes = 100 - (duration % 100);
- time = (hours * 60) + minutes;
- }
- else
- {
- duration = (end + 2400) - begin;
- hours = duration / 100;
- minutes = 100 - (duration % 100);
- time = (hours * 60) + minutes;
- }
- System.out.println("\nCall summary:");
- System.out.print("Started at " + hours + " for " + minutes + " minutes.");
- console.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement