Advertisement
Guest User

Untitled

a guest
May 12th, 2016
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 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 Coding_101_24._04._2016
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int age = int.Parse(Console.ReadLine());
  14. decimal price = decimal.Parse(Console.ReadLine());
  15. int toyPrice = int.Parse(Console.ReadLine());
  16.  
  17. int toys = 0;
  18. int money = 0;
  19. int countSteels = 0;
  20. for (int i = 1; i <= age; i++)
  21. {
  22. if (i%2==0)
  23. {
  24. money += i * 10 / 2;
  25. countSteels++;
  26. }
  27. else
  28. {
  29. toys++;
  30. }
  31. }
  32. decimal sellToysMoney = toys * toyPrice;
  33. decimal totalMoney = sellToysMoney - countSteels+money;
  34. if (totalMoney>=price)
  35. {
  36. Console.WriteLine("Yes! {0:f2}",totalMoney-price);
  37. }
  38. else
  39. {
  40. Console.WriteLine("No! {0:f2}",price-totalMoney);
  41. }
  42.  
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement