// 9.5.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include #include using namespace std; void GetInput(int& hrs, int& min, int& sec); void Output(int hrs, int min, int sec, int format=0); int main() { int hrs, min, sec; GetInput(hrs, min, sec); Output(hrs, min, sec); Output(hrs, min, sec, 1); Output(hrs, min, sec, 2); } void GetInput(int& hrs, int& min, int& sec) { cout << "Input the hour in 24 hour time: "; cin >> hrs; cout << "\nInput the minute: "; cin >> min; cout << "\nInput the second: "; cin >> sec; cout << "\n\n"; } void Output(int hrs, int min, int sec, int format) { if (format == 2) { cout << "Showing in 24-hour time:\n"; cout << setw(2) << setfill('0') << hrs << ":" << setw(2) << min << ":" << setw(2) << sec << "\n"; } else if (format == 1) { cout << "Showing in military time:\n"; cout << setw(2) << setfill('0') << hrs << setw(2) << min << ":" << setw(2) << sec << "\n"; } else { cout << "Showing in regular time:\n"; if (hrs >= 12) { cout << hrs-12 << ":" << setw(2) << setfill('0') << min << ":" << setw(2) << sec << " PM" << "\n"; } else { cout << hrs << ":" << setw(2) << setfill('0') << min << ":" << setw(2) << sec << " AM" << "\n"; } } }