Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ The input should read in integer values for the hours, read in the colon character and discard it, and eger values for the minutes.

image text in transcribed
C++
The input should read in integer values for the hours, read in the colon character and discard it, and eger values for the minutes. Three user defined functions should be used with the tion prototypes: getInput(int &hrs, int min) void convertTime(int Shrs, string &m); void displayoutput (int hrs, int min, string arpm) The function getInput) should be used to store the hours and minuties input from the keyboard using reference parameters. The function convertTime) should be used to convert the hours from 24-hour format to 12-hour format and determine the AM PM information using reference parameters The function displayoutput) should print out the results of the time conversion in 12-hour format using call by value parameters. NOTE: The string data type is defined in the std namespace. Therefore, "using namespace std "must be declared globally before your function prototypes since the displayoutput) function uses the string data type. Otherwise, use std::string to refer to all string data types The setw() function will be needed to ensure that two spaces are always used for the minutes. To force a leading "0'to be printed in the case of "08 minutes, the setfill) function should be used as well. Any blank spaces that are present due to the setw) function will be filled by a character passed to the setfill) function as an argument. Since we require 2 spaces to print out the minutes, and we always want to print the lcading "0'if nocessary, setw(2) and setfii1can be used to format the output just before printing the minutes to the screen Note that printing a leading 0' for the hours is not necessary. These functions are present in the LO Manipelation library As an example, if you execute the program with the following underlined inputs, the output will be - main.o Enter a time in 24 hour format: 24100 Time: 12:00 AM -main.o Enter a tine in 24 hour format: 12:00 Time: 12:00 PM Enter a time in 24 hour format: 00108 Time: 12:08 AM Enter a time in 24 hour format: 03:09 Time: 3:09 AM -main.o Enter a time in 24 hour format: 18:50 Time: 6:50 PM

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

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions