Guest User

Untitled

a guest
Jul 1st, 2016
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. class SmartLilly
  4. {
  5. static void Main()
  6. {
  7. int age = int.Parse(Console.ReadLine());
  8. decimal washingPrice = decimal.Parse(Console.ReadLine());
  9. int toyPrice = int.Parse(Console.ReadLine());
  10. int toys = 0;
  11. int money = 0;
  12. int m = 0;
  13. int n = 0;
  14. decimal totalMoney = 0;
  15. decimal change = 0;
  16. for (int i = 1; i <= age; i++)
  17. {
  18. if (i % 2 == 0)
  19. {
  20. m += 10;
  21. money = money + m;
  22. n++;
  23. }
  24. else
  25. {
  26. toys++;
  27. }
  28. }
  29. totalMoney = (toys * toyPrice) + (money - n);
  30. if (washingPrice <= totalMoney)
  31. {
  32. change = totalMoney - washingPrice;
  33. Console.WriteLine("Yes! {0:F2}", change);
  34. }
  35. else
  36. {
  37. change = washingPrice - totalMoney;
  38. Console.WriteLine("No! {0:F2}", change);
  39. }
  40. }
  41. }
Add Comment
Please, Sign In to add comment