Reference Parameters (returning multiple values): Write a C++ function that conv
ID: 673466 • Letter: R
Question
Reference Parameters (returning multiple values): Write a C++ function that converts standard time to military time. Inputs include hours and minutes in standard time and a character equal to ‘a’ for am or ‘p’ for pm.
The function call might look like:
MilitaryTime(SHour, SMin, AorP, MHour, MMin);
Also write a main program to prompt the user for the inputs (such as 1:30 am), call the function, and display the input and the output in the following form:
12:30 am = 0030
2:30 am = 0230
3:30pm = 1530
12:00 am = 0000
Run the program for the four cases above
Hint: Using fill(’0’) is an easy way to show leading zeros.
.
Explanation / Answer
#include using namespace std; class Time { private: int hour; int minute; public: void setTime(int &x, int &y) { while((x > 24) || (y > 60)) { cerr > y; } if(xRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.