Advertisement
SomeoneX

12. Clever Lily

Nov 14th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _12.Clever_Lily
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int age = int.Parse(Console.ReadLine());
  14. double priceWashingMachine = double.Parse(Console.ReadLine());
  15. int priceToy = int.Parse(Console.ReadLine());
  16.  
  17. int toyCount = 0;
  18. int moneyCount = 0;
  19. int totalMoney = 0;
  20. int stolenMoney = 0;
  21.  
  22. for (int i = 1; i <= age; i++)
  23. {
  24. if (i % 2 == 0)
  25. {
  26. moneyCount += 10;
  27. totalMoney += moneyCount;
  28. stolenMoney++;
  29. }
  30. else
  31. {
  32. toyCount++;
  33. }
  34. }
  35.  
  36. double soldToys = toyCount * priceToy;
  37.  
  38. double finalPrice = (totalMoney + soldToys) - stolenMoney;
  39.  
  40. if (finalPrice >= priceWashingMachine)
  41. {
  42. Console.WriteLine($"Yes! {finalPrice - priceWashingMachine:F2}");
  43. }
  44. else
  45. {
  46. double diff =Math.Abs(priceWashingMachine - finalPrice);
  47. Console.WriteLine($"No! {diff:F2}");
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement