Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language is C++ undefined 2. Time 24 Hours Language: C++ Autocomplete Ready Define a class Time24, that has the private time, minutes, and seconds attributes.

Language is C++

image text in transcribedundefined

2. Time 24 Hours Language: C++ Autocomplete Ready Define a class Time24, that has the private time, minutes, and seconds attributes. It has following functions: - Time24(int h, int m, int s) initializes the attributes, also supports default values. - Time24(int h, int m, int s, char p) initializes the attributes given in 12 hours format. p is given as 'a' or 'p', indicating if it's am/pm. - void add(Time24 time) adds the time to the current time of object. - void adjust() to adjust the time to a valid 24 hours, this function should do the adjustment. For code re- utilization purposes this function can be called from constructor, and add function. (should it be a private function?? Yes, probably it should be define in private scope, as this will be used internally inside the class) - void show() displays the time in 24 hours format. Make this function constant, so that can be called with constant object. 1 #include 2 3 using namespace std; 4 v int main() { 5 int hoursi, minutesi, seconds1; 6 cin>>hours1>>minutes1>>secondsl; 7 Time24 ti(hoursi, minutesi, seconds1); 8 9 int hours2, minutes2, seconds2; char period; cin>>hours2>>minutes2>>seconds2>>period; const Time24 t2 = {hours2, minutes2, seconds2, period} 10 11 12 13 14 15 16 17 18 19 20 main function is provided, you have to make it working. cout

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_2

Step: 3

blur-text-image_3

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions