Write a program that requests the current time and a waiting time as two integers for the number of hours and the number of minutes to wait. The program then outputs what the time will be after the waiting period. Use 24 hour notation for the times. Include a loop that lets the user repeat thiscalculation for additional input values until the user says she or he wants to end the program.
Program:
#include<iostream>
using namespace std;
void main()
{
int currHours,currMins,hoursWait,minutesWait;
int hrs,min;
char choice;
do
{
cout<<"Enter present Hours:";
cin>>currHours;
cout<<"Enter present minutes:";
cin>>currMins;
cout<<"Enterthe number of hours to wait:";
cin>>hoursWait;
cout<<"Enter the number of minutes to wait:";
cin>>minutesWait;
hrs=currHours+hoursWait;
min=currMins+minutesWait;
if(min>=60)
{
hrs++;
min =min-60;
}
cout<<"Time:"<<hrs<<":"<<min<<endl;
cout<<"Do you want to continue then press y or Y:";
cin>>choice;
}while(choice == 'Y' || choice =='y');
}
Output:
Enter present Hours:10
Enter present minutes:20
Enterthe number of hours to wait:2
Enter the number of minutes to wait:10
Time:12:30
Do you want to continue then press y or Y:n