Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_HHMM = 5;
  5. const int MAX_DAY = 2;
  6. void call_input(char time_of_call[]);
  7. void time_text(bool start_or_finish);
  8. void day_of(char day_of_week[]);
  9. int main()
  10. {
  11.  
  12.     char start_of_call[MAX_HHMM + 1];
  13.     char end_of_call[MAX_HHMM + 1];
  14.     char day_of_week[MAX_DAY + 1];
  15.  
  16.     cout << "This program will calculate long distance\n"
  17.          << "-----------------------------------------\n\n";
  18.     time_text(true);
  19.     call_input(start_of_call);
  20.     time_text(false);
  21.     call_input(end_of_call);
  22.     day_of(day_of_week);
  23.     return 0;
  24. }
  25. void day_of(char day_of_week[])
  26. {
  27.     cout << "\nEnter a date"
  28.          << "in the format of"
  29.          << "\n Mon Tue Wed Thu Fri Sat Sun > ";
  30.     cin >> day_of_week;
  31.     day_of_week[sizeof(day_of_week) -1] = '\0';
  32.     return;
  33. }
  34.  
  35. void call_input(char time_of_call[])
  36. {
  37.     char yes_or_no[4] = "no";
  38.     cin >> time_of_call;
  39.     time_of_call[sizeof(time_of_call) - 1] = '\0';
  40.     while(yes_or_no[0] != 'y' && yes_or_no[1] != 'e' && yes_or_no[2] !='s') {
  41.         cout << "\nYour time was " << time_of_call
  42.              << "\nIs this correct > ";
  43.         cin >> yes_or_no;
  44.         yes_or_no[sizeof(yes_or_no) -1] = '\0';
  45.         if(yes_or_no[0] != 'y' && yes_or_no[1] !='e' && yes_or_no[2] !='s') {
  46.             cout << "Enter the time again > ";
  47.             cin >> time_of_call;
  48.             time_of_call[sizeof(time_of_call) - 1] = '\0';
  49.         }
  50.     }
  51.     return;
  52. }
  53.  
  54. void time_text(bool start_or_finish)
  55. {
  56.     if (start_or_finish == true) {
  57.     cout << "enter the time your call started HH:MM > ";
  58.     }
  59.     if (start_or_finish == false) {
  60.     cout << "enter the time your call ended HH:MM > ";
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement