Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#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 hour format to hour format
void cHourint hour int minute, int &hour string &period
if hour
hour;
period AM;
else if hour
hour;
period PM;
else if hour
hour hour;
period PM;
else
hour hour;
period AM;
int mainstring
int hour minute;
int houranswer,yY;
char colon;
string period;
cout "Military Time Converter to Standard Time" hour colon minute;
Validate Input
cHourhour minute, hour period;
do
if hour && hourcout hour colon minute && hour
cout hour colon minute minute minute
cout is not valid time" endl;
else
;
cout "Would you like to convert time? yn endl;
cin answer;
Convert to hour format
while answer y answer Y;
Display the time in hour format
return ;
my code above is giving me this output. MilitaryTimeConvertertoStandardTime
InputMilitaryTimehhmm:
::PM
Wouldyouliketoconverttimeyn
what do i need to change to recieve
Expected Output
MilitaryTimeConvertertoStandardTime
InputMilitaryTimehh:mm
::PM
Wouldyouliketoconvertanothertimeyn
::AM
Wouldyouliketoconvertanothertimeyn
::PM
Wouldyouliketoconvertanothertimeyn
:isnotavalidtime
Wouldyouliketoconvertanothertimeyn
:isnotavalidtime
Wouldyouliketoconvertanothertimeyn
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started