BdW44222

Untitled

May 9th, 2020
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace Loops
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int age = int.Parse(Console.ReadLine());
  10. double washingMachine = double.Parse(Console.ReadLine());
  11. double toyPrice = double.Parse(Console.ReadLine());
  12. double moneyFromBirthdays = 0;
  13. double moneyGift = 10;
  14. int numOfToys = 0;
  15.  
  16.  
  17. for (int birthday = 1; birthday <= age; birthday++)
  18. {
  19. if(birthday % 2 == 0)
  20. {
  21. moneyFromBirthdays += moneyGift;
  22. moneyGift += 10;
  23. moneyFromBirthdays--;
  24.  
  25. }
  26. else
  27. {
  28. numOfToys++;
  29. }
  30.  
  31. double totalMoneyFromToys = numOfToys * toyPrice;
  32. double totalMoney = totalMoneyFromToys + moneyFromBirthdays;
  33.  
  34. if(washingMachine <= totalMoney)
  35. {
  36. Console.WriteLine($"Yes! {totalMoney - washingMachine:F2}");
  37. }
  38. else
  39. {
  40. Console.WriteLine($"No! {washingMachine - totalMoney:F2}");
  41. }
  42. }
  43. }
  44. }
  45. }
RAW Paste Data