/****************************************************** ** Name: ** Filename: DateTimeDrv.cpp ** Project #: Deitel & Deitel 6.10 ** Project Description: Combine the modified Time class of Exercise 6.8 and the modified Date class of Exercise 6.9 into one class called DateAndTime. Modify the ticks function to call the nextDay function if the time is incremented into the next day. Modify function printStandard and printMilitary to output the date in addition to the time. Write a driver program to test the new class DateAndTime. Specifically, test incrementing the time into the next day. ** Output: Print out Starting Standard Time, Starting Military Time, and Starting Date as entered by user. Print out the Standard Time, Military Time and Date that would result from 3 second increments. ** Input: Enter Starting Hour = 1 - 24 Enter Starting Minutes = 0 - 60 Enter Starting Seconds = 0 - 60 Enter Starting Month = 1 - 12 Enter Starting Day = 1 - 31 Enter Starting Year = Format(2002) ** Algorithm: Create Driver File vbdriver.cpp Include the DateandTime.h header In the DateandTime Header Identify a Time class and a Date class and declare functions and variables. Make a DateandTime.cpp file with the functions Time Date PrintMilitary PrintStandard nextDay LeapYear Use the int main() in the vbdriver to call the functions through the DateandTime.h header file from the DateandTime.cpp file. Print to screen purpose of program Print to screen instructs to enter Time and Date to start at Print to screen the time and date starting at Print the time and date incremented in a 3 second interval. End Program ******************************************************/ // Include files #include // used for cin, cout #include #include #include "DateTime.h" using namespace std; // Global Type Declarations // Function Prototypes void instruct (void); void pause (); void incrementSeconds( Time &, const int, Date & ); //Global Variables - should not be used without good reason. int main () { // Declaration section //Time Time t; int a, //Hour b, //Minutes c, //Seconds x, //Month y, //Day z; //Year // Executable section instruct (); cout << "Set The Time To Start At Below\n" << "Starting Hour: "; cin >> a; t.setHour( a ); cout << "Starting Minutes: "; cin >> b; t.setMinute( b ); cout << "Starting Seconds: "; cin >> c; t.setSecond( c); cout << "\nSet The Date To Start At Below\n" << "Starting Month: "; cin >> x; cout << "Starting Day: "; cin >> y; cout << "Starting Year: "; cin >> z; //Date Date d( x, y, z ); t.setTime( a, b, c ); incrementSeconds( t, 3, d ); pause (); return 0; } void incrementSeconds(Time &tt, const int count, Date &d ) { cout << "\nIncrementing In Seconds " << count << " times:\nStandard Time: "; tt.printStandard(); cout << " Military Time: "; tt.printMilitary(); cout << "\t"; d.print(); for ( int i = 0; i < count; i++ ) { tt.setSecond( ( tt.getSecond() + 1 ) % 60); if ( tt.getSecond() == 0 ){ tt.setMinute( ( tt.getMinute() + 1 ) % 60); if ( tt.getMinute() == 0 ) tt.setHour( ( tt.getHour() + 1 ) % 24); if ( tt.getHour() == 0 ) d.nextDay(); } cout << "\n Second + 1: "; tt.printStandard(); cout << "\t\t "; tt.printMilitary(); cout << "\t"; d.print(); } cout << endl; } void instruct (void) { // Declaration section cout << "This program will take the starting time and date entered by " << "the user and print\nit out in standard format and military " << "format. It will also increment the time\nby 3 seconds to show " << "the changing of the time. In addition to this it will also roll " << "the date over to the next day and the year to the next year if it " << "is\ndetermined to be needed.\n" << "_______________________________________________________________" << "________________" << "\n" << endl; pause(); // Executable section } void pause () { // Declaration section // Executable section cout << "\nPress any key to continue..."; getch(); cout << "\r"; cout << " "; cout << "\r"; } /* Program Output This program will take the starting time and date entered by the user and print it out in standard format and military format. It will also increment the time by 3 seconds to show the changing of the time. In addition to this it will also roll the date over to the next day and the year to the next year if it is determined to be needed. _______________________________________________________________________________ Set The Time To Start At Below Starting Hour: 11 Starting Minutes: 59 Starting Seconds: 58 Set The Date To Start At Below Starting Month: 12 Starting Day: 31 Starting Year: 2002 Incrementing In Seconds 3 times: Standard Time: 11:59:58 AM Military Time: 11:59:58 Date Is: 12-31-2002 Second + 1: 11:59:59 AM 11:59:59 Date Is: 12-31-2002 Second + 1: 12:00:00 PM 12:00:00 Date Is: 12-31-2002 Second + 1: 12:00:01 PM 12:00:01 Date Is: 12-31-2002 Press any key to continue... Set The Time To Start At Below Starting Hour: 23 Starting Minutes: 59 Starting Seconds: 58 Set The Date To Start At Below Starting Month: 12 Starting Day: 31 Starting Year: 2002 Incrementing In Seconds 3 times: Standard Time: 11:59:58 PM Military Time: 23:59:58 Date Is: 12-31-2002 Second + 1: 11:59:59 PM 23:59:59 Date Is: 12-31-2002 Second + 1: 12:00:00 AM 00:00:00 Date Is: 1-1-2003 Second + 1: 12:00:01 AM 00:00:01 Date Is: 1-1-2003 Press any key to continue... */