viraco4a

Simple_Loops_UmnataLily

Feb 7th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 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 _15_exam3_SmartLily
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double age = double.Parse(Console.ReadLine());
  14. double laundryPrice = double.Parse(Console.ReadLine());
  15. double gamePrice = double.Parse(Console.ReadLine());
  16. double money = 0.0;
  17.  
  18. for (int i = 1; i <= age; i++)
  19. {
  20. if (i % 2 == 0)
  21. {
  22. money += ((i / 2.0) * 10 - 1);
  23. }
  24. else
  25. {
  26. money += gamePrice;
  27. }
  28. }
  29. double diff = Math.Abs(money - laundryPrice);
  30. if (money >= laundryPrice)
  31. {
  32. Console.WriteLine($"Yes! {diff:f2}");
  33. }
  34. else
  35. {
  36. Console.WriteLine($"No! {diff:f2}");
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment