Advertisement
dimanou_04

Untitled

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