C++ clock program

I have to create a program that does the following:
Create at least two functions beside the main function. One to take user input and one to display the output. The program must also handle up to 24 hours of waiting time,ie (the next day). For example if the start time is 22:00 and the wait time is 4:10. then the correct result is 2:10, not 26:10. I also will need to use reference parameters to handle user input.

This is what I have so far but I am very lost.
using namespace std;

int main()
int current_hour, current_min, waiting_hour, waiting_min, total_hour, total_min;
char ans;

cout << "Compute completion time from current time and waiting period" << endl;
cout << "Current time: " << endl;
cout << "Enter 24 hour time in the format HH:MM" << endl;
cin >> current_hour, ":", current_min;

cout << "Waiting time: " << endl;
cout << "Enter 24 hour time in the format HH:MM" << endl;
cin >> waiting_hour, ":", waiting_min;

total_hour = current_hour + waiting_hour;
total_min = current_min + waiting_min;

cout << "Completion Time in 24 hour format: ";
cout << total_hour << ":" << total_min << endl;

cout << "Enter Y or y to continue, any other halts program
cin >> ans;
while(ans == 'y' || ans == 'Y');

return 0;


I created these:
void get_input(current_hour, current_min, waiting_hour, waiting_min)

int wait_time(total_hour, total_min)

void give_results(current_hour, current_min, waiting_hour, waiting_min, total_hour, total_min)

But, I'm not sure what to do with them? Any suggestions?


  • This should not be that difficult. Simply work the minutes first and see if they are greater than 60. If so, subtract 60 and add one to the sum of the hours. If the hours are greater than 24 adjust again. This should be pretty straightforward math.

    Take Care,
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion