mattnguyen

Untitled

Feb 28th, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2.  
  3. namespace For_Cycle
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int age = int.Parse(Console.ReadLine());
  10. double priceOfWashingMachine = double.Parse(Console.ReadLine());
  11. double priceofOneToy = double.Parse(Console.ReadLine());
  12.  
  13. int toysCounter = 0;
  14. double moneyHolder = 0;
  15. int stolenMoney = 0;
  16. double moneyPresent = 0;
  17.  
  18. for (int currentYear = 1; currentYear <= age; currentYear++)
  19. {
  20. if (currentYear % 2 != 0)
  21. {
  22. toysCounter++;
  23. }
  24. else
  25. {
  26. stolenMoney++;
  27. moneyHolder = moneyPresent;
  28. moneyPresent += 10;
  29. }
  30. }
  31.  
  32. double moneyFromToys = toysCounter * priceofOneToy;
  33.  
  34. double finalResult = (moneyHolder + moneyFromToys) - stolenMoney;
  35.  
  36.  
  37.  
  38. if (finalResult >= priceOfWashingMachine)
  39. {
  40. Console.WriteLine($"Yes! ({(finalResult - priceOfWashingMachine):f2})");
  41. }
  42. else
  43. {
  44. Console.WriteLine($"No! {(priceOfWashingMachine - finalResult):f2}");
  45. }
  46. }
  47. }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment