Modify your program for Programming Project 2 so that it uses 12 hour notation, such as 3:45 PM.
Program:
#include<iostream>
using namespace std;
void main()
{
int currHours,currMins,hoursWait,minutesWait;
int hrs,min;
char ch;
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;
}
if(hrs>12)
{
hrs=hrs%12;
cout<<"Time:"<<hrs<<":"<<min<<"PM"<<endl;
}
else
{
cout<<"Time:"<<hrs<<":"<<min<<"AM"<<endl;
}
cout<<"Enter y or Y to continue...";
cin>>ch;
}while(ch == 'y' || ch =='Y');
}
Output:
Enter present Hours:19
Enter present minutes:30
Enterthe number of hours to wait:20
Enter the number of minutes to wait:15
Time:3:45PM
Enter y or Y to continue...n