C++ Classes Exercises |
Next > |
// From ADTs, Data Structures, and Problem Solving with C++, 2e by Larry Nyhoff #include <iostream> #include "Time.h" using namespace std; struct Time{ unsigned int hour, minute; char AMorPM; // 'A' or 'P' unsigned int milTime; // military time equivalent }; int main(){ Time mealTime, goToWorkTime; set(mealTime, 5, 30, 'P'); cout << "We'll be eating at "; display(mealTime, cout); cout << endl; set(goToWorkTime, 5, 30, 'P'); cout << "You leave for work at "; display(goToWorkTime, cout); cout << endl; if (lessThan(mealTime, goToWorkTime)){ cout << "If you hurry, you can eat first.\n"; }else{ cout << "Sorry you can't eat with us.\n"; } advance(goToWorkTime, 0, 30); cout << "Your boss called. You go in later at "; display(goToWorkTime, cout); cout << endl; if (lessThan(mealTime, goToWorkTime)){ cout << "If you hurry, you can eat first.\n"; }else{ cout << "Sorry you can't eat with us.\n"; } cout << endl; }
Last Modified: