Question: C++ Implement a program to convert hours from 24 hours format to AM/PM format, as follows: Ask the user to enter the time. e.g. for

C++ Implement a program to convert hours from 24 hours format to AM/PM format, as follows:

Ask the user to enter the time. e.g. for 14:45, the hour (14) and the minute (45) are entered by user separately as integers.

Make the conversion to PM format.

Write the result output that will print the time properly formatted saying some greetings according to the current time. e.g. 2:45 PM Good Afternoon!

Implement the code using at least 3 functions: input; convert; and output;

From the main function, after create the method named convertTimeAPI, call the convertTimeAPI function; the function convertTimeAPI is used as the method/function that is the starting point that calls all other functions.

The given starting code to work from:

/* * 24-hour to 12-hour time converter * May crash or produce unreasonable results if provided invalid input */

#include using namespace std; //Takes hour and minute input from the console in 24-hour format void input(void) { int hour = 0; int minute = 0; char ampm = 'A'; //AM or PM

bool done = false; char consoleInput;

cout << "Enter only the hour without minutes in 24-hour format" << endl; cin >> hour; cout << "Please enter the minutes" << endl; cin >> minute; } //Converts 24-hour time to 12-hour time //to do

//Prints the time in 12-hour format //to do

// main function int main(void) {

input();

return 0; }

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!