Question: #ifndef TIME_H #define TIME_H #include using namespace::std; /*The class Time is used to manipulate schedules. It is composed of 3 attributes or data member that

#ifndef TIME_H #define TIME_H #include using namespace::std;

/*The class Time is used to manipulate schedules. It is composed of 3 attributes or data member that represent the hour, the minute and the second. These data members were named hour, minute, and second by the developer of this class. The hours stores a value between 0-23, the minutes and the second stores values between 0-59*/

class Time {

private: int hour; // 0-23 int minute; // 0-59 int second; //0-59

public: Time(int = 0, int = 0, int = 0); // Constructor. Note that the default schedule is 00:00:00

void setTime(int, int, int); void setHour(int); void setMinute(int); void setSecond(int);

int getHour(); int getMinute(); int getSecond(); void printUniversal(); // 00:00:00 void printStandard(); // 0:00:00 AM/PM

};

#endif

#include #include using namespace::std;

#include "Time.h"

Time::Time(int h, int m, int s) { setTime(h, m, s); }

void Time::setTime(int h, int m, int s) { setHour(h); setMinute(m); setSecond(s); }

void Time::setHour(int h) { if (h >= 0 && h < 24) hour = h; else hour = 0; }

void Time::setMinute(int m) { if (m >= 0 && m < 60) minute = m; else minute = 0; }

void Time::setSecond(int s) { if (s >= 0 && s < 60) second = s; else second = 0; }

int Time::getHour() { return hour; }

int Time::getMinute() { return minute; }

int Time::getSecond() { return second; }

void Time::printUniversal() { cout << setfill('0') << setw(2) << hour << ':' << setw(2) << minute << ':' << setw(2) << second; }

void Time::printStandard() { if (hour == 0 || hour == 12) cout << 12; else cout << hour % 12;

cout << ':' << setfill('0') << setw(2) << minute << ':' << setw(2) << second;

if (hour < 12) cout << " AM"; else cout << " PM"; }

Using the following code, answer these questions regarding on constructing the main function

#include #include using namespace::std;

#include "Time.h"

int main() {

/*Question 1: Write an instruction to create an object of type Time called t1, and initialized that object with a schedule corresponding 3 in the morning.*/ ________________;

/*Question 2: Write an instruction to crear an object of type Time called t2, and initialized that object with a schedule corresponding 3:30 in the afternoon.*/ ________________;

/*Question 3: Write an instruction to crear an object of type Time called t3, and initialized that object with a schedule default (12 midnight).*/ _________________;

/*Question 4: Write an instruction that prints the first object defined before, t1, in universal format.*/ cout << "Value of t1 in universal format: "; _________________; /*Question 5: Write an instruction that prints the first object defined before, t1, in standard format.*/ cout << "Value of t1 in standard format: "; _________________;

/*Question 6: 3 Parts Complete the following cout's for them to print the content of the second object, t2, int the following format: Hour: 15 Minute: 30 Second: 0*/ cout << "Hour:\t" << _________; cout << " Minute\t" << __________; cout << " Second:\t" << ____________;

/*Presume that you have varibles hr, min and sec and they are defined as int and the user is asked for their information with the code presented below. Complete the following questions after this piece of code:*/ int hr, min, sec;

cout << "Enter the hour: (0..23):"; cin >> hr; while (hr < 0 || hr >= 24) { cout << "Hour inv Re-enter hour (0.23):"; cin >> hr; }

cout << "Enter the minute (0..59):"; cin >> min; while (min < 0 || min >= 60) { cout << "Minute inv Re-enter minute (0..59):"; cin >> min; }

cout << "Enter the second (0..59):"; cin >> sec; while (sec < 0 || sec >= 60) { cout << "Second inv Re-enter second (0..59):"; cin >> sec; }

/*Question 1: Write an instruction that puts in the object t1 the values of hr, min, and sec that have just been requested from the user.*/ _____________

/*Question 8 and 9: If we assume that the user entered the values: hr = 13, min = 50, sec = 45, and that the same are stored in t1 with the instruction that you have just written, answer the following:

Question 8: What would the printStandard function of the class print when the content of object t1 is sent to print now?*/ ______________

/*Question 9: What would the printUniversal function of the class print when the content of object t1 is sent to print now ? */ _____________

/*Question 10: Write the instruction that allows you to change the value of hour of the object t1, to put a 20. The instruction only wants to modify the hour of object t1.*/ _____________

/*Question 11: Write the instruction that puts a 90 in the value of hour of object t2. Note: as of now the object t2 had the value of 3:30 in the afternoon.*/ _______________

/*Questions 12 and 13: After the instructions from before: Question 12: What does the program print now if I use the printUniversal function to print the schedules stored in value t2?*/ ______________ /*Question 13: Is the instruction t2.hour corerect to access the value of the hour of object 2, defined from before?*/ Yes or No ?

/*Question 14: Write an instruction that defines a pointer of the name pt as a pointer to an object type of Time*/ ____________

return 0;

}

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!