Advertisement
avr39ripe

costDiscountBad

Sep 30th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     float haveMoney{ 0 };
  6.     float cost{ 0 };
  7.  
  8.     std::cout << "Enter money sum you have\n";
  9.     std::cin >> haveMoney;
  10.  
  11.     std::cout << "Enter cost of goods you witsh to buy\n";
  12.     std::cin >> cost;
  13.  
  14.     if (cost >= 2000)
  15.     {
  16.         std::cout << "Cost with discount is " << cost * 0.9 << '\n';
  17.         if (cost * 0.9 > haveMoney)
  18.         {
  19.             std::cout << "Oops! You haven't enough money to pay!\n";
  20.             std::cout << "Find another " << cost * 0.9 - haveMoney << " $$$ and try again!\n";
  21.         }
  22.         else
  23.         {
  24.             std::cout << "You have enough money!\n Cost with discount is " << cost * 0.9 << '\n';
  25.         }
  26.     }
  27.     else if ( cost >= 1500)
  28.     {
  29.         std::cout << "Cost with discount is " << cost * 0.93 << '\n';
  30.         if (cost * 0.93 > haveMoney)
  31.         {
  32.             std::cout << "Oops! You haven't enough money to pay!\n";
  33.             std::cout << "Find another " << cost * 0.93 - haveMoney << " $$$ and try again!\n";
  34.         }
  35.         else
  36.         {
  37.             std::cout << "You have enough money!\n Cost with discount is " << cost * 0.93 << '\n';
  38.         }
  39.     }
  40.     else if (cost >= 1000)
  41.     {
  42.         std::cout << "Cost with discount is " << cost * 0.95 << '\n';
  43.         if (cost * 0.95 > haveMoney)
  44.         {
  45.             std::cout << "Oops! You haven't enough money to pay!\n";
  46.             std::cout << "Find another " << cost * 0.95 - haveMoney << " $$$ and try again!\n";
  47.         }
  48.         else
  49.         {
  50.             std::cout << "You have enough money!\n Cost with discount is " << cost * 0.95 << '\n';
  51.         }
  52.     }
  53.     else
  54.     {
  55.         std::cout << "Cost WITHOUT discount is " << cost << '\n';
  56.         if (cost > haveMoney)
  57.         {
  58.             std::cout << "Oops! You haven't enough money to pay!\n";
  59.             std::cout << "Find another " << cost - haveMoney << " $$$ and try again!\n";
  60.         }
  61.         else
  62.         {
  63.             std::cout << "You have enough money!\n";
  64.         }
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement