Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions