Advertisement
Spocoman

07. Shopping

Sep 3rd, 2023 (edited)
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     double budget;
  8.     cin >> budget;
  9.  
  10.     int gpu, cpu, ram;
  11.     cin >> gpu >> cpu >> ram;
  12.  
  13.     int gpuPrice = gpu * 250;
  14.     double cpuPrice = cpu * gpuPrice * 0.35;
  15.     double ramPrice = ram * gpuPrice * 0.10;
  16.  
  17.     double totalPrice = gpuPrice + cpuPrice + ramPrice;
  18.  
  19.     if (gpu > cpu) {
  20.         totalPrice *= 0.85;
  21.     }
  22.  
  23.     cout.setf(ios::fixed);
  24.     cout.precision(2);
  25.  
  26.     if (budget >= totalPrice) {
  27.         cout << "You have " << budget - totalPrice << " leva left!" << endl;
  28.     }
  29.     else {
  30.         cout << "Not enough money! You need " << totalPrice - budget << " leva more!" << endl;
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement