Question: #include #include #include / / For setw and setfill using namespace std; / / Function to convert 2 4 - hour format to 1 2

#include
#include
#include // For setw and setfill
using namespace std;
// Function to convert 24-hour format to 12-hour format
void c12Hour(int hour24, int minute, int &hour12, string &period){
if (hour24==0){
hour12=12;
period ="AM";
} else if (hour24==12){
hour12=12;
period ="PM";
} else if (hour24>12){
hour12= hour24-12;
period ="PM";
} else {
hour12= hour24;
period ="AM";
}
}
int main(string){
int hour24, minute;
int hour12,answer,y,Y;
char colon;
string period;
cout << "Military Time Converter to Standard Time"<> hour24>> colon >> minute;
// Validate Input
c12Hour(hour24, minute, hour12, period);
do{
if (hour24>=0 && hour24<=11){cout << hour24<< colon << minute<<"="<11 && hour24<=23){
cout << hour24<< colon << minute<<"="<=24|| minute <0|| minute >=60){
cout <<"is not valid time" << endl;
}
else {
};
cout<< "Would you like to convert time? (y/n)"<< endl;
cin>> answer;
}
// Convert to 12-hour format
while (answer =='y'|| answer =='Y');
// Display the time in 12-hour format
return 0;
}
my code above is giving me this output. MilitaryTimeConvertertoStandardTime
InputMilitaryTime(hhmm):
14:25=02:25PM
Wouldyouliketoconverttime?(y/n)
what do i need to change to recieve
Expected Output
MilitaryTimeConvertertoStandardTime
InputMilitaryTimehh:mm
14:25=2:25PM
Wouldyouliketoconvertanothertime(y/n)
00:15=12:15AM
Wouldyouliketoconvertanothertime(y/n)
12:15=12:15PM
Wouldyouliketoconvertanothertime(y/n)
12:69isnotavalidtime
Wouldyouliketoconvertanothertime(y/n)
25:25isnotavalidtime
Wouldyouliketoconvertanothertime(y/n)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!