desislava_topuzakova

07. Fruit Market

Jan 10th, 2021
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     //ягоди, банани, портокали и малини
  9.     //цена и количество
  10.  
  11.     //1. сума за ягодите = цена на ягодите/кг * количество -> DONE
  12.      //2. сума за малини = цена за малини/кг * количество -> DONE
  13.     //3. сума за банани = цена на банани/кг * количество -> DONE
  14.     //4. сума за портокали = цена за портокали/кг * количество -> DONE
  15.    
  16.     //сума = сума от ягодите + сума от банани + сума от портокали + сума от малини
  17.  
  18.     double strawberryPrice, bananaQuantity, orangeQuantity, raspberryQuantity, strawberryQuantity;
  19.     cin >> strawberryPrice >> bananaQuantity >> orangeQuantity >> raspberryQuantity >> strawberryQuantity;
  20.  
  21.     //ЯГОДИ
  22.     double strawberrySum = strawberryPrice * strawberryQuantity;
  23.  
  24.     //МАЛИНИ
  25.     double raspberryPrice = strawberryPrice / 4;
  26.     double raspberrySum = raspberryPrice * raspberryQuantity;
  27.  
  28.     //БАНАНИ
  29.     double bananaPrice = raspberryPrice - 0.8 * raspberryPrice; //0.2 * raspberryPrice
  30.     double bananaSum = bananaPrice * bananaQuantity;
  31.  
  32.     //ПОРТОКАЛИ
  33.     double orangePrice = 0.6 * raspberryPrice; // raspberryPrice - 0.4 * raspberryPrice;
  34.     double orangesSum = orangePrice * orangeQuantity;
  35.  
  36.  
  37.     double totalSum = strawberrySum + raspberrySum + bananaSum + orangesSum;
  38.  
  39.     cout.setf(ios::fixed);
  40.     cout.precision(2);
  41.  
  42.     cout << totalSum << endl;
  43.  
  44.  
  45.  
  46.  
  47. }
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment