Advertisement
Spocoman

07. Flower Shop

Sep 4th, 2023 (edited)
721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     const double MAGNOLIA_PRICE = 3.25;
  8.     const double HYACINTH_PRICE = 4.00;
  9.     const double ROSE_PRICE = 3.50;
  10.     const double CACTUS_PRICE = 8.00;
  11.     const double TAX_PROFIT = 0.05;
  12.    
  13.     int magnoliaCount, hyacinthCount, roseCount, cactusCount;
  14.     cin >> magnoliaCount >> hyacinthCount >> roseCount >> cactusCount;
  15.  
  16.     double giftPrice;
  17.     cin >> giftPrice;
  18.  
  19.     double totalSum = (MAGNOLIA_PRICE * magnoliaCount + HYACINTH_PRICE * hyacinthCount + ROSE_PRICE * roseCount + CACTUS_PRICE * cactusCount) * (1 - TAX_PROFIT);
  20.  
  21.     if (totalSum >= giftPrice) {
  22.         cout << "She is left with " << floor(totalSum - giftPrice) << " leva." << endl;
  23.     }
  24.     else {
  25.         cout << "She will have to borrow " << ceil(giftPrice - totalSum) << " leva." << endl;
  26.     }
  27.    
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement