Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language is C++ 1 v #include 1. Time 2 3 using namespace std; 4 Create a class called Time that has separate int member data

Language is C++image text in transcribed

1 v #include 1. Time 2 3 using namespace std; 4 Create a class called Time that has separate int member data for hours, minutes, and seconds. One constructor should initialize this data to 0, and another should initialize it to passed values. Another member function (show) should display it, in 23:59:59 format. There should be overloaded + operator that adds the time of the object passed, and returns a Time object. A main() program is given, where two initialized time objects are created. Then it adds the two initialized objects together, leaving the result in the third time object. Finally it displays the value of all the time objects. 11 5 6 v int main() { 7 /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 8 int hh, mm, ss; 9 cin>>hh>>mm>>ss; 10 Time ti(hh, mm, ss); //ti(hh, mm, ss) cin>>hh>>mm>>ss; 12 Time t2 (hh, mm, ss); 13 Time t3; 14 t3=t1+t2; //adding two times should produce a valid time, overflowed hours/minutes/seconds should be adjusted. 15 // e.g. adding 18:10:20 with 10:20:30 results in 4:30:50 16 17 ti.show(); 18 t2.show(); 19 t3.show(); 20 return 0; 21 If any number exceeds its limit, it should be carried forward. For example, if the seconds are more than 59, they should carry forward to minutes. If the hours are more than 23, they can be truncated, as it will carry forward to next day

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

What is a core competency?

Answered: 1 week ago

Question

1. Signs and symbols of the map Briefly by box ?

Answered: 1 week ago

Question

Types of physical Maps?

Answered: 1 week ago

Question

Explain Intermediate term financing in detail.

Answered: 1 week ago