Write a program to convert the time from 24-hour notation to 12-hour notation an
ID: 3679688 • Letter: W
Question
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following function: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.) including comments
Explanation / Answer
using namespace std; void input_timein24hourformat(int hours, int minutes); void convert_24_to_12_format(int hours, int AMPM); void output_12_hour_format(int hours, int minutes, int AMPM); int main () { int hours; int minutes; int AMPM; char Ahere, Phere; input_timein24houtformat(); convert_24_to_12_format(hours); output_12_hour_format(); void input_timein24hourformat(int hours, int minutes); { cout > hours; cout > minutes; } //to convert the time from 24 hour format to 12 void convert_24_to_12_format(int hours, int AMPM); { if( hours < 12) { hours = hours; minutes = minutes; AMPM = 'Ahere'; } if( hours > 12) { hours = hours - 12; minutes = minutes; AMPM = 'Phere'; } } void output_12_hour_format(int hours, int minutes, int AMPM); { if(AMPM =='Phere') { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.