mstoyanov7

3zad

Jan 28th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7.     string type;
  8.     int cnt, budget;
  9.     cin >> type >> cnt >> budget;
  10.  
  11.     double discount = 0;
  12.     double price = 0;
  13.  
  14.     if (type == "Roses") {
  15.         price = 5;
  16.         if (cnt > 80) {
  17.             discount = price * 0.1;
  18.         }
  19.     }
  20.     else if (type == "Dahlias") {
  21.         price = 3.8;
  22.         if (cnt > 90) {
  23.             discount = price * 0.15;
  24.         }
  25.     }
  26.     else if (type == "Tulips") {
  27.         price = 2.8;
  28.         if (cnt > 80) {
  29.             discount = price * 0.15;
  30.         }
  31.     }
  32.     else if (type == "Narcissus") {
  33.         price = 3;
  34.         if (cnt < 120) {
  35.             price *= 1.15;
  36.         }
  37.     }
  38.     else if (type == "Gladiolus") {
  39.         price = 2.5;
  40.         if (cnt < 80) {
  41.             price *= 1.2;
  42.         }
  43.     }
  44.     double finalPrice = cnt * (price - discount);
  45.     cout.setf(ios::fixed);
  46.     cout.precision(2);
  47.  
  48.     if (budget >= finalPrice) {
  49.         cout << "Hey, you have a great garden with " << cnt << " " << type << " and " << budget - finalPrice << " leva left." << endl;
  50.     }
  51.     else {
  52.         cout << "Not enough money, you need " << finalPrice - budget << " leva more." << endl;
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment