Advertisement
Guest User

code

a guest
Sep 30th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Highway {
  6. public :
  7.  
  8. string IsCrash();
  9. double WhatTime() ;
  10. double GetTime();
  11.  
  12. private:
  13. double militaryTime;
  14. double timeOfDay;
  15. string crash;
  16. };
  17.  
  18. class Driver {
  19. public:
  20. double TripEta();
  21.  
  22.  
  23.  
  24. private:
  25. double tripDistance;
  26. double driversMph;
  27. double totalDistance;
  28.  
  29. };
  30.  
  31. string Highway::IsCrash() {
  32.  
  33.  
  34. cout << "I see you if you are wondering it is ok to take the highway right now." << endl << "Was there a crash? (Y/N?)" << endl;
  35.  
  36. cin >> crash;
  37.  
  38. return crash;
  39. }
  40.  
  41.  
  42.  
  43. double Highway::WhatTime () {
  44.  
  45. cout << "Futhermore, what time of day is it?" << endl << "Enter in military time format" << "(Ex. 0.30 = 12:30 midnight, 1.00 = 1:00am, etc.)" << endl;
  46.  
  47. cin >> militaryTime;
  48.  
  49. return militaryTime;
  50. }
  51.  
  52. double Highway::GetTime() {
  53.  
  54. militaryTime = timeOfDay;
  55. return timeOfDay;
  56. }
  57.  
  58. double Driver::TripEta() {
  59.  
  60. cout << "How many miles is the trip?" << endl;
  61.  
  62. cin >> tripDistance;
  63.  
  64. cout << "How many miles are you going per hour?" << endl;
  65.  
  66. cin >> driversMph;
  67.  
  68. totalDistance = (tripDistance / driversMph) * 60;
  69.  
  70. return totalDistance;
  71.  
  72.  
  73. }
  74.  
  75.  
  76. int main()
  77. {
  78. Highway crash;
  79. Highway timeOfDay;
  80. Driver tripInMiles;
  81.  
  82.  
  83. if ( (crash.IsCrash() == "Y" && tripInMiles.TripEta() > 60.0) || (timeOfDay.GetTime() >= 7.30 && timeOfDay.GetTime() <= 8.30) )
  84. {
  85. cout << "It is advised to avoid the highway, find an alternate route." << endl;
  86.  
  87. }
  88. else {
  89. cout << "It is determined it is efficient " << endl;
  90. }
  91.  
  92. system("pause");
  93. return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement