Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. cout << "Please enter your destination travel start time (HH:MM): " << endl;
  2. cin >>dest_startHOUR>>dest_startMIN;
  3.  
  4. cout << "Please enter your destination travel end time (HH:MM): " << endl;
  5. cin >>dest_endHOUR>>dest_endMIN;
  6.  
  7. cout << "Please enter your home travel start time (HH:MM): " << endl;
  8. cin >>home_startHOUR>>home_startMIN;
  9.  
  10. cout << "Please enter your home travel end time (HH:MM): " << endl << endl;
  11. cin >>home_endHOUR>>home_endMIN;
  12. cout << "Departed from " << home_city << " at " << dest_startHOUR << ":" << dest_startMIN << "." << endl;
  13. cout << "Traveled " << dest_miles << " miles to " << dest_city << ", arrived at " << dest_endHOUR << ":" << dest_endMIN << ". " << "Travel time, " << dest_endHOUR - home_startHOUR << "." << (dest_endMIN - home_startMIN) / 60 << " hours."<< endl << endl;
  14.  
  15. Please enter your destination travel start time (HH:MM):
  16. 04:30
  17. Please enter your destination travel end time (HH:MM):
  18. Please enter your home travel start time (HH:MM):
  19. Please enter your home travel end time (HH:MM):
  20. Departed from CityA at 4:0.
  21. Traveled 200 miles to CityB, arrived at 0:0. Travel time, 0.0 hours.
  22.  
  23. Please enter your destination travel start time (HH:MM): 05:30
  24. Please enter your destination travel end time (HH:MM): 07:45
  25. Please enter your home travel start time (HH:MM): 06:15
  26. Please enter your home travel end time (HH:MM): 08:30
  27.  
  28. Departed from CityA at 05:30.
  29. Traveled 100 miles to CityB, arrived at
  30. 07:45. Travel time, 2.25 hours.
  31.  
  32. #include <iostream>
  33. #include <string>
  34. #include <iomanip>
  35. #include <string>
  36.  
  37. using namespace std;
  38.  
  39. ...
  40.  
  41. int dest_startHOUR, dest_startMIN;
  42. int dest_endHOUR, dest_endMIN;
  43. int home_startHOUR, home_startMIN;
  44. int home_endHOUR, home_endMIN;
  45. int dest_miles;
  46. string home_city, dest_city;
  47. char c;
  48.  
  49. ...
  50.  
  51. cout << "Please enter your destination travel start time (HH:MM): ";
  52. cin >> dest_startHOUR >> c >> dest_startMIN;
  53. cin.clear();
  54. cin.ignore(numeric_limits<streamsize>::max(), 'n');
  55.  
  56. cout << "Please enter your destination travel end time (HH:MM): ";
  57. cin >> dest_endHOUR >> c >> dest_endMIN;
  58. cin.clear();
  59. cin.ignore(numeric_limits<streamsize>::max(), 'n');
  60.  
  61. cout << "Please enter your home travel start time (HH:MM): ";
  62. cin >> home_startHOUR >> c >> home_startMIN;
  63. cin.clear();
  64. cin.ignore(numeric_limits<streamsize>::max(), 'n');
  65.  
  66. cout << "Please enter your home travel end time (HH:MM): ";
  67. cin >> home_endHOUR >> c >> home_endMIN;
  68. cin.clear();
  69. cin.ignore(numeric_limits<streamsize>::max(), 'n');
  70.  
  71. cout << endl;
  72. cout << "Departed from " << home_city << " at " << setw(2) << setfill('0') << dest_startHOUR << ":" << dest_startMIN << "." << endl;
  73. cout << "Traveled " << dest_miles << " miles to " << dest_city << ", arrived at " << setw(2) << setfill('0') << dest_endHOUR << ":" << dest_endMIN << ". " << endl;
  74. cout << "Travel time, " << dest_endHOUR - home_startHOUR << "." << (dest_endMIN - home_startMIN) / 60 << " hours." << endl;
  75. cout << endl;
  76.  
  77. #include <iostream>
  78. #include <string>
  79. using namespace std;
  80.  
  81. int main()
  82. {
  83. int dest_startHOUR, dest_startMIN;
  84. int dest_endHOUR, dest_endMIN;
  85. int home_startHOUR, home_startMIN;
  86. int home_endHOUR, home_endMIN;
  87. int dest_miles = 200;
  88. string home_city = "CityA", dest_city = "CityB";
  89. char ch;
  90.  
  91. cout << "Please enter your destination travel start time (HH:MM): ";
  92. cin >> dest_startHOUR >> ch >> dest_startMIN;
  93.  
  94. cout << "Please enter your destination travel end time (HH:MM): ";
  95. cin >> dest_endHOUR >> ch >> dest_endMIN;
  96.  
  97. cout << "Please enter your home travel start time (HH:MM): ";
  98. cin >> home_startHOUR >> ch >> home_startMIN;
  99.  
  100. cout << "Please enter your home travel end time (HH:MM): ";
  101. cin >> home_endHOUR >> ch >> home_endMIN;
  102.  
  103. cout << "Departed from " << home_city << " at " << dest_startHOUR << ":" << dest_startMIN << "." << endl;
  104. cout << "Traveled " << dest_miles << " miles to " << dest_city
  105. << ", arrived at " << dest_endHOUR << ":" << dest_endMIN << ". "
  106. << "Travel time, " << dest_endHOUR - dest_startHOUR << "." << (dest_endMIN - dest_startMIN) / 60.0 * 100
  107. << " hours." << endl << endl;
  108.  
  109. return 0;
  110. }
  111.  
  112. Please enter your destination travel start time (HH:MM): 05:30
  113. Please enter your destination travel end time (HH:MM): 07:45
  114. Please enter your home travel start time (HH:MM): 06:15
  115. Please enter your home travel end time (HH:MM): 08:30
  116. Departed from CityA at 5:30.
  117. Traveled 200 miles to CityB, arrived at 7:45. Travel time, 2.25 hours.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement