Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace zadachi
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. int age = int.Parse(Console.ReadLine());
  11. double washingmashine = double.Parse(Console.ReadLine());
  12. double toyPrice = double.Parse(Console.ReadLine());
  13. double savedMoney = 0;
  14. int toyCount = 0;
  15. double moneyByToys = 0;
  16. int moneyByBrother = 0;
  17.  
  18. for (int i = 1; i <= age; i++)
  19. {
  20. if (i % 2 == 0)
  21. {
  22. savedMoney += i * 5;
  23. moneyByBrother++;
  24. }
  25. else
  26. {
  27. toyCount++;
  28. moneyByToys = toyCount * toyPrice;
  29. }
  30. }
  31. double totalMoney = (savedMoney - moneyByBrother) + moneyByToys;
  32. if (totalMoney >= washingmashine)
  33. {
  34. Console.WriteLine($"Yes! {totalMoney - washingmashine:f2}");
  35. }
  36. else
  37. {
  38. Console.WriteLine($"No! {washingmashine - totalMoney:f2}");
  39. }
  40.  
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement