Advertisement
Spocoman

Computer Room

Sep 3rd, 2024 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string month;
  7.     cin >> month;
  8.    
  9.     int hours, people;
  10.     cin >> hours >> people;
  11.     cin.ignore();
  12.        
  13.     string time;
  14.     cin >> time;
  15.        
  16.     double price = 0;
  17.  
  18.     if (month == "march" || month == "april" || month =="may") {
  19.         if (time == "day") {
  20.             price = 10.50;
  21.             hours = 3;
  22.         } else {
  23.             price = 8.40;
  24.         }
  25.     } else if (month == "june" || month == "july" || month == "august") {
  26.         if (time == "day") {
  27.             price = 12.60;
  28.         } else {
  29.             price = 10.20;
  30.         }
  31.     }
  32.  
  33.     if (people >= 4) {
  34.         price *= 0.9;
  35.     }
  36.  
  37.     if (hours >= 5) {
  38.         price /= 2;
  39.     }
  40.  
  41.     double total = price * people * hours;
  42.  
  43.     printf("Price per person for one hour: %.2f\n", price);
  44.     printf("Total cost of the visit: %.2f\n", total);
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement