Advertisement
wigllytest

Untitled

Aug 7th, 2020
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7.  
  8. int age, toyPrice;
  9. double wachingPrice;
  10.  
  11. cin >> age >> wachingPrice >> toyPrice;
  12.  
  13. int moneyPresent = 0;
  14. int present = 0;
  15. int moneyBonus = 10;
  16.  
  17. for (int i = 1; i <= age; i++)
  18. {
  19.  
  20. if (i % 2 == 0)
  21. {
  22. moneyPresent += moneyBonus - 1;
  23. moneyBonus += 10;
  24. }
  25. else
  26. {
  27. present += 1;
  28. }
  29. }
  30.  
  31. double liliMoney = (present * toyPrice) + moneyPresent;
  32.  
  33. cout.setf(ios::fixed);
  34. cout.precision(2);
  35.  
  36. if (liliMoney >= wachingPrice)
  37. {
  38. cout << "Yes! " << liliMoney - wachingPrice << endl;
  39. }
  40. else
  41. {
  42. cout << "No! " << wachingPrice - liliMoney << endl;
  43.  
  44. }
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement