desislava_topuzakova

01. Fruit Marker

Feb 19th, 2022
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     //ягоди (цена ,кг), банани (кг), портокали (кг) и малини (кг)
  7.    
  8.     //входни данни
  9.     double strawberriesPrice;
  10.     cin >> strawberriesPrice;
  11.  
  12.     double bananasQuantity;
  13.     cin >> bananasQuantity;
  14.  
  15.     double orangesQuantity;
  16.     cin >> orangesQuantity;
  17.  
  18.     double raspberriesQuantity;
  19.     cin >> raspberriesQuantity;
  20.  
  21.     double strawberriesQuantity;
  22.     cin >> strawberriesQuantity;
  23.  
  24.     //обща сума = (strawberriesQuantity * strawberriesPrice)
  25.     //          + (bananasQuantity * bananasPrice)
  26.        //       + (raspberriesQuantity * raspberriesPrice)
  27.        //       + (orangesQuantity * orangesPrice)
  28.    
  29.     double raspberriesPrice = strawberriesPrice / 2;
  30.     double bananasPrice = raspberriesPrice - 0.8 * raspberriesPrice; //0.2 * raspberriesPrice
  31.     double orangesPrice = raspberriesPrice - 0.4 * raspberriesPrice; //0.6 * raspberriesPrice
  32.  
  33.     double totalSum = (strawberriesQuantity * strawberriesPrice)
  34.         + (bananasQuantity * bananasPrice)
  35.         + (raspberriesQuantity * raspberriesPrice)
  36.         + (orangesQuantity * orangesPrice);
  37.  
  38.     cout.setf(ios::fixed);
  39.     cout.precision(2);
  40.  
  41.     cout << totalSum << endl;
  42.     return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment