public class JobTake { public static void main(String[] args) { //Current time (e.g., 11:45). int hour = 11; int minute = 45; int total = 60 * hour + minute; //How long will the job take (e.g., 2 hours and 20 minutes) int jhour = 2; int jminute = 20; total = total + 60 * jhour + jminute; //A simpler way to say the above line is //total += 60 * jhour + jminute; //Break the total back down into hours and minutes. hour = total / 60; //quotient minute = total % 60; //remainder /* The hours of the clock run from 1 to 12 inclusive. But it would be easier for the % operator if they ran from 0 to 11 inclusive, since the value of any number % 12 is in the range 0 to 11 inclusive. We therefore subtract 1 from hour before we apply the % operator, and then add the 1 back on afterwards. */ hour = hour - 1; //A simpler way to say the above line is //--hour; //Knock the hour down into the range 0 to 11 inclusive. hour = hour % 12; //A simpler way to say the above line is //hour %= 12; hour = hour + 1; //A simpler way to say the above line is //++hour; System.out.print("The job will be finished at " + hour + ":"); //Print the minute as a two-digit number. if (minute < 10) { System.out.print("0"); } System.out.println(minute + "."); } }