Guest User

Untitled

a guest
Jun 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. //File: timeApp.cpp
  2. //Author: Derek Acker
  3. //Date: Spring 2012
  4. //Course: CSC 136
  5. //Description:
  6.  
  7. #include<cstdlib>
  8. #include<iostream>
  9. #include"myTime.h"
  10.  
  11. using namespace std;
  12.  
  13. int getChoice(int& choice);
  14. myTime getTime();
  15. void displayMil(myTime time);
  16. void displayStd(myTime stdTime);
  17. myTime changeTime(myTime &time);
  18. myTime checkTime(myTime time, myTime nextTime);
  19.  
  20. int main()
  21. {
  22. int choice;
  23. myTime theTime, nextTime;
  24.  
  25.  
  26. while((choice = getChoice(choice))!=6)
  27. {
  28. switch (choice)
  29. {
  30. case 1: theTime = getTime(); break;
  31. case 2: displayMil(theTime); break;
  32. case 3: displayStd(theTime); break;
  33. case 4: changeTime(theTime); break;
  34. case 5: checkTime(theTime, nextTime); break;
  35. }
  36. }
  37.  
  38. system("PAUSE");
  39. return 0;
  40. }
  41.  
  42. int getChoice(int& choice)
  43. {
  44. cout << "1. Enter a time" << endl;
  45. cout << "2. Display as 24 hour time" << endl;
  46. cout << "3. Display as 12 hour time" << endl;
  47. cout << "4. Change time" << endl;
  48. cout << "5. Check earlier" << endl;
  49. cout << "6. Quit" << endl;
  50. cout << "Choice: ";
  51. cin >> choice;
  52.  
  53. while (choice < 1 || choice > 6)
  54. {
  55. cout << "You must enter a number between 1 and 6." << endl;
  56. cout << "Please enter your option again: ";
  57. cin >> choice;
  58. }
  59. return choice;
  60. }
  61.  
  62. myTime getTime()
  63. {
  64. myTime time;
  65. cout << "Enter time ex: 12:45" << endl;
  66. cin >> time;
  67. return time;
  68. }
  69.  
  70. void displayMil(myTime time)
  71. {
  72. cout << time << endl;
  73. }
  74.  
  75. void displayStd(myTime stdTime)
  76. {
  77. stdTime.showClock();
  78. }
  79.  
  80. myTime changeTime(myTime &time)
  81. {
  82. int min, hour;
  83. cout << "Enter minutes to be changed: " << endl;
  84. cin >> min;
  85. time.setMinutes(min);
  86.  
  87. cout << "Enter hours the be changed: " << endl;
  88. cin >> hour;
  89. time.setHours(hour);
  90. }
  91.  
  92. myTime checkTime(myTime time, myTime nextTime)
  93. {
  94. }
Add Comment
Please, Sign In to add comment