Advertisement
Guest User

Untitled

a guest
Aug 15th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main ()
  8. {
  9.     double budget;
  10.     int fishers;
  11.     string season;
  12.  
  13.     cin >> budget >> season >> fishers;
  14.  
  15.     double basePrice = 4200.0;
  16.  
  17.     if (season == "Spring")
  18.     {
  19.         basePrice = 3000.0;
  20.     }
  21.     else if (season == "Winter")
  22.     {
  23.         basePrice = 2600.0;
  24.     }
  25.  
  26.     double priceModifier = 0.9;
  27.  
  28.     if (fishers > 11)
  29.     {
  30.         priceModifier = 0.75;
  31.     }
  32.     else if (fishers > 6)
  33.     {
  34.         priceModifier = 0.85;
  35.     }
  36.  
  37.     if (fishers % 2 == 0 && season != "Autumn")
  38.     {
  39.         priceModifier *= 0.95;
  40.     }
  41.  
  42.     double finalPrice = basePrice * priceModifier;
  43.  
  44.     cout.setf(ios::fixed);
  45.     cout.precision(2);
  46.  
  47.     if(budget >= finalPrice)
  48.     {
  49.         cout << "Yes! You have " << budget - finalPrice << " leva left." << endl;
  50.     }
  51.     else if (budget<finalPrice)
  52.     {
  53.         cout << "Not enough money! You need " << finalPrice - budget << " leva." << endl;
  54.     }
  55.  
  56.     return 0 ;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement