Question: Modify in C++, c plus plus, cpp, the Time project below so that: 1) The Time fields hour minute and second can only be initialized

Modify in C++, c plus plus, cpp, the Time project below so that:

1) The Time fields hour minute and second can only be initialized to valid values.

2) The printStandardTime() and printUniversalTime() display time correctly for any valid time (am or pm).

//Main

#include #include "time.h" /* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) { Time mTime; mTime.setTime(18,12,30); mTime.printStandard(); mTime.printUniversal(); return 0; }

//Time.cpp

#include #include #include "Time.h" using namespace std;

// constructor Time::Time(){ hour = minute = second = 0; }

void Time::setTime(int h, int m, int s){ hour = h; minute = m; second = s; }

void Time::printStandard(){ cout << " " << hour << ":" << minute << ":" << second << endl; }

void Time::printUniversal(){ cout << " " << hour << ":" << minute << ":" << second << endl; }

//Time.h

#ifndef TIME_H #define TIME_H

class Time{ public: Time(); void setTime(int, int, int); void printUniversal(); void printStandard(); private: int hour; int minute; int second; }; #endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!