Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using a 24-hour clock representation, time is generally expressed in terms of ho

ID: 3652165 • Letter: U

Question

Using a 24-hour clock representation, time is generally expressed in terms of hours and minutes past midnight of the current day. For example, 2:30 would represent "2 hours and 30 minutes past midnight", and 13:21 would represent "13 hours and 21 minutes past midnight". Time periods longer than 24 hours are represented modulo 24, e.g. 24:01 would be represented as 00:01 of the following day.

Part 1: Write a C++ function named addTime() that will add an integer number of minutes to a time-of-day value represented by two separate integers: hours and minutes.

You need to do the following:
1. Write the function definition for addTime() that will accept three integer arguments: the current time hours value, current time minutes value and the number of minutes to be added to the current time. Your function should update the values for both hours and minutes. The updated values must be in proper format with the hours value between (0,23) and the minutes value between (0,60). (Hint: think about the % operator)
2. Write a main() driver program that prompts the user to enter the hours and minutes values for the time of day and also the number of minutes to add to the time value.
3. Have the main() function call addTime() and display the updated time value on the console in the following format: hh:mm with a ':' character separating the values.


Part 2: Now, overload the function name addTime() by constructing a second version of the addTime() function that takes 4 integer arguments: the hours and minutes of the current time and an amount of time to add in hours and minutes. Hint: convert the hours, minutes to be added to minutes and simply call the first version of addTime.

Explanation / Answer

#include void addTime(int& CurrentTimeHour,int& CurrentTimeMinute,int minutes) { int temp=CurrentTimeHour*60+CurrentTimeMinute+minutes; temp=temp%(24*60); CurrentTimeHour=temp/60; CurrentTimeMinute=temp%60; } void addTime(int& CurrentTimeHour,int& CurrentTimeMinute,int minutes,int hours) { addTime(CurrentTimeHour,CurrentTimeMinute,60*hours+minutes); } int main() { int CurrentTimeHour; int CurrentTimeMinute; int minutes; coutCurrentTimeHour; coutCurrentTimeMinute; coutminutes; addTime(CurrentTimeHour,CurrentTimeMinute,minutes); std::cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote