Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c + + Display the Clocks This function takes in three parameters, h , m , and s , which represent the hours ( 0

c++ Display the Clocks
This function takes in three parameters, h, m, and s, which represent the hours (0-23), minutes (0-59), and seconds (0-59) of the current time, respectively.
You can assume that you have access to the following functions:
nCharString(n, c): Returns a string of n characters, where each character is c.
formatTime12(h, m, s): Returns the formatted time in 12-hour clock format, given the current time in hours, minutes, and seconds.
formatTime24(h, m, s): Returns the formatted time in 24-hour clock format, given the current time in hours, minutes, and seconds.
To complete this function, follow the comments provided:
Print a line consisting of 27 stars, 3 spaces, and another 27 stars.
Print a line consisting of 1 star, 6 spaces, "12-HOUR CLOCK", 6 spaces, another star, and 3 spaces.
Print a line consisting of 1 star, 6 spaces, "24-HOUR CLOCK", 6 spaces, another star, and a line break.
Print a blank line.
Print a line consisting of 1 star, 6 spaces, the formatted time in 12-hour clock format, 7 spaces, another star, and 3 spaces.
Print a line consisting of 1 star, 8 spaces, the formatted time in 24-hour clock format, 9 spaces, another star, and a line break.
Print a line consisting of 27 stars, 3 spaces, and another 27 stars.
Here's the function signature for reference:
void displayClocks(unsigned int h, unsigned int m, unsigned int s){
// TODO: Your code here, follow the comments for each line
}
Solution
Language: cpp
1
/**
2
* Display the clocks
3
*
4
* @param h, hours 0 to 23
5
* @param m, minutes 0 to 59
6
* @param s, seconds 0 to 59
7
*/
8
void displayClocks(unsigned int h, unsigned int m, unsigned int s){
9
// The code in your submitted program may vary. For now, please get this to work with the given
10
// function signature.
11
// You may assume you have a working nCharString and formatTime24 and formatTime12 and has been imported
12
//
13
// nCharString(27,'*') gives a string of 27 stars. nCharString(3,'') gives 3 spaces
14
// formatTime12(h, m, s) and formatTime24(h, m, s) give the formatted time as specified in the assignment
15
// test will pass in (0,59,9)
16
// TODO: Your code here, follow the comments for each line
17
// cout 27 stars +3 spaces +27 stars + endl
18
// cout 1 star +6 spaces +12-HOUR CLOCK +6 spaces +1 star +3 spaces
19
// cout 1 star +6 spaces +24-HOUR CLOCK +6 spaces +1 star + endl
20
// cout an endl for a blank line
21
// cout 1 star +6 spaces + formatTime12(h, m, s)+7 spaces +1 star +3 spaces
22
// cout 1 star +8 spaces + formatTime24(h, m, s)+9 spaces +1 star + endl
23
// cout 27 stars +3 spaces +27 stars + endl
24
}

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

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago

Question

1. Discuss the four components of language.

Answered: 1 week ago

Question

f. What stereotypes were reinforced in the commercials?

Answered: 1 week ago