Advertisement
alexbancheva

Clever Lilly

Nov 16th, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Clever_Lilly
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int age = int.Parse(Console.ReadLine());
  10. double priceWashingMachine = double.Parse(Console.ReadLine());
  11. int priceForOneToy = int.Parse(Console.ReadLine());
  12.  
  13. int toysCounter = 0;
  14. int savedMoney = 0;
  15. int stolenMoney = 0;
  16. int prevBirthday = 0;
  17.  
  18. for (int currentBirthday = 1; currentBirthday <= age; currentBirthday++)
  19. {
  20. if (currentBirthday % 2 != 0 )
  21. {
  22. toysCounter++;
  23. }
  24. else
  25. {
  26. savedMoney += 10;
  27. prevBirthday += savedMoney;
  28. stolenMoney++;
  29. }
  30. }
  31.  
  32. int totalMoneyFromToys = priceForOneToy * toysCounter;
  33. int totalSavedMoney = (prevBirthday + totalMoneyFromToys) - stolenMoney;
  34.  
  35. if (priceWashingMachine <= totalSavedMoney)
  36. {
  37. Console.WriteLine($"Yes! {Math.Abs(priceWashingMachine - totalSavedMoney):f2}");
  38. }
  39. else
  40. {
  41. Console.WriteLine($"No! {Math.Abs(totalSavedMoney - priceWashingMachine):f2}");
  42. }
  43. }
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement