Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
C++
Specifications: 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 convertTine(int Shrs, stringampm) void displayoutput (int hrs, int min, string ampm) The function getInput should be used to store the hours and minutes input from the keyboard using reference parameters. The function convertTime) should be used to convert the hours from 24-hour format to 12-bour format and determine the AM PM information using reference parameters. The fanction 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 stdistring to refer to all string data types The setw() fanction will be needed to ensure that two spaces are always used for the minutes. To force a leading'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 leading O' if necessary, setw(2) and setfill can be used to format the output just before printing the minutes to the screen. Note that printing a leading 0' for the hours iomanip> is not necessary. These functions are i anipulation library As an example, if you execute the program with the following underlined inputs, the output will be Enter a time in 24 hour formati 24:00 Time: 12:00 AM -main.o Enter a time in 24 hour formati 12:00 Time: 12:00 PM main.o Enter a time in 24 hour format: 00:08 Time: 12:08 AM -main.o Enter a time in 24 hour format: 03:09 Time: 3:09 AM 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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

Students also viewed these Databases questions