Advertisement
Spocoman

03. New House

Sep 5th, 2023
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     const double ROSE_PRICE = 5;
  7.     const double DAHLIA_PRICE = 3.8;
  8.     const double TULIP_PRICE = 2.8;
  9.     const double NARCISSYS_PRICE = 3;
  10.     const double GLADIOLUS_PRICE = 2.5;
  11.  
  12.     string flower;
  13.     cin >> flower;
  14.  
  15.     int quantity;
  16.     cin >> quantity;
  17.  
  18.     double budget;
  19.     cin >> budget;
  20.  
  21.     double sum;
  22.  
  23.     if (flower == "Roses") {
  24.         sum = ROSE_PRICE * quantity;
  25.         if (quantity > 80) {
  26.             sum *= 0.9;
  27.         }
  28.     }
  29.     else if (flower == "Dahlias") {
  30.         sum = DAHLIA_PRICE * quantity;
  31.         if (quantity > 90) {
  32.             sum *= 0.85;
  33.         }
  34.     }
  35.     else if (flower == "Tulips") {
  36.         sum = TULIP_PRICE * quantity;
  37.         if (quantity > 80) {
  38.             sum *= 0.85;
  39.         }
  40.     }
  41.     else if (flower == "Narcissus") {
  42.         sum = NARCISSYS_PRICE * quantity;
  43.         if (quantity < 120) {
  44.             sum *= 1.15;
  45.         }
  46.     }
  47.     else if (flower == "Gladiolus") {
  48.         sum = GLADIOLUS_PRICE * quantity;
  49.         if (quantity < 80) {
  50.             sum *= 1.2;
  51.         }
  52.     }
  53.  
  54.     cout.setf(ios::fixed);
  55.     cout.precision(2);
  56.  
  57.     if (sum > budget) {
  58.         cout << "Not enough money, you need " << sum - budget << " leva more." << endl;
  59.     }
  60.     else {
  61.         cout << "Hey, you have a great garden with " << quantity << " " << flower << " and " << budget - sum << " leva left.";
  62.     }
  63.  
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement