Advertisement
Spocoman

04. Toy Shop

Sep 1st, 2023 (edited)
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     double amount;
  7.     cin >> amount;
  8.  
  9.     int puzzles, dolls, bears, minions, trucks;
  10.     cin >> puzzles >> dolls >> bears >> minions >> trucks;
  11.  
  12.     double puzzlePrice = puzzles * 2.6;
  13.     double dollsPrice = dolls * 3;
  14.     double bearsPrice = bears * 4.1;
  15.     double minionsPrice = minions * 8.2;
  16.     double trucksPrice = trucks * 2;
  17.     int toys = puzzles + dolls + bears + minions + trucks;
  18.     double price = puzzlePrice + dollsPrice + bearsPrice + minionsPrice + trucksPrice;
  19.  
  20.     if (toys >= 50) {
  21.         price *= 0.75;
  22.     }
  23.  
  24.     price *= 0.9;
  25.  
  26.     cout.setf(ios::fixed);
  27.     cout.precision(2);
  28.  
  29.     if (price >= amount) {
  30.         cout << "Yes! " << price - amount << " lv left." << endl;
  31.     }
  32.     else {
  33.         cout << "Not enough money! " << amount - price << " lv needed." << endl;
  34.     }
  35.    
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement