Advertisement
YavorJS

Smart Lilli

Jul 1st, 2016
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4.  
  5. class Program
  6. {
  7. static void Main()
  8. {
  9.  
  10. int N = int.Parse(Console.ReadLine());
  11. double woundryPrice = double.Parse(Console.ReadLine());
  12. int singleToyPrice = int.Parse(Console.ReadLine());
  13. int numberOfToys = 0;
  14. int presentInMoney = 0;
  15. int totalPresentsInMoney = 0;
  16.  
  17. for (int i = 1; i <= N; i++)
  18. {
  19. if (i%2!=0)
  20. {
  21. numberOfToys += 1;
  22. }
  23. else if(i%2==0)
  24. {
  25. presentInMoney += 10;
  26. totalPresentsInMoney += presentInMoney-1;
  27. }
  28. }
  29. int MoneyFromToys = numberOfToys * singleToyPrice;
  30.  
  31. double moneyCollected = MoneyFromToys + totalPresentsInMoney;
  32.  
  33. if (moneyCollected>= woundryPrice)
  34. {
  35. Console.WriteLine("Yes! {0:f2}", moneyCollected-woundryPrice);
  36. }
  37. else
  38. {
  39. Console.WriteLine("No! {0:f2}", woundryPrice-moneyCollected);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement