Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iomanip>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. double calculateCharges(double h){
  8.     if (h <= 3){
  9.         return 2.00;
  10.     }
  11.     else
  12.     {
  13.         if (h < 24)
  14.             return  2.00 + (h - 3) * 0.5;
  15.         else{
  16.             return 10.00;
  17.         }
  18.  
  19.     }
  20. }
  21.  
  22. int main(){
  23.    
  24.     double h = 0;
  25.     double totalh = 0;
  26.     double totalm = 0;
  27.  
  28.     while(h > -1){
  29.         cout << "input the amount of hours the vehicle parked: ";
  30.         cin >> h;
  31.         cout << endl;
  32.         cout << "This person pays: " << calculateCharges(h) << endl;
  33.         totalh += h;
  34.         totalm += calculateCharges(h);
  35.     }
  36.     cout << "the total time is: " << totalh << endl;
  37.     cout << "the total $ is: " << totalm << endl;
  38.     system("PAUSe");
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement