am trying to do this assignment, but I can't, can some help or coach me thru this.
Write a program that reads two times in military format (0940, 1705) and prints the number of hours and minutes between the two times. Here is a sample run.
Please enter the first time: 0940
Please enter the second time: 1705
7 hours 25 minutes
Use a Time class with a constructor that takes an integer-based military time as a parameter and a method difference that takes a Time object as a parameter and returns a Time object.
Note: The times should be input in the order in which they occur. For example, for 0940 on Monday and 1705 on Monday, the first time is 0940, and the second time is 1705. For 1705 on Monday and 0940 on Tuesday, the first number is 1705, and the second number is 0940.
Hint: To account for negative time differences, as in the second instance described above, add one day (24 * 60 minutes) to the difference and then find the remainder that results from dividing the result by the number of minutes in a day. That is, timeDifference = (timeDifference + MINUTES_PER_DAY ) % MINUTES_PER_DAY . Note that this calculation will not make a difference in a case of a positive time difference, but it will make the proper adjustment in a case of a negative time difference.
Write a program that reads two times in military format (0940, 1705) and prints the number of hours and minutes between the two times. Here is a sample run.
Please enter the first time: 0940
Please enter the second time: 1705
7 hours 25 minutes
Use a Time class with a constructor that takes an integer-based military time as a parameter and a method difference that takes a Time object as a parameter and returns a Time object.
Note: The times should be input in the order in which they occur. For example, for 0940 on Monday and 1705 on Monday, the first time is 0940, and the second time is 1705. For 1705 on Monday and 0940 on Tuesday, the first number is 1705, and the second number is 0940.
Hint: To account for negative time differences, as in the second instance described above, add one day (24 * 60 minutes) to the difference and then find the remainder that results from dividing the result by the number of minutes in a day. That is, timeDifference = (timeDifference + MINUTES_PER_DAY ) % MINUTES_PER_DAY . Note that this calculation will not make a difference in a case of a positive time difference, but it will make the proper adjustment in a case of a negative time difference.
Comment