Advertisement
plamen27

Back in the past fixed

Jul 18th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 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 Back_To_The_Past
  8. {
  9. class back_past
  10. {
  11. static void Main(string[] args)
  12. {
  13. double money = double.Parse(Console.ReadLine());
  14. int year = int.Parse(Console.ReadLine());
  15. ///int ivanchosYears = -1782; //// няма нужда от тази променлива, сметната беше грешно, ако искаш да използваш използвай тази
  16.  
  17.  
  18. double totalExpences = 0;
  19.  
  20. for (int i = 1800; i <= year; i++)
  21. {
  22.  
  23. if (i % 2 == 0)
  24. {
  25.  
  26. totalExpences += 12000;
  27. }
  28. else if (i % 2 != 0)
  29. {
  30. totalExpences = totalExpences + (12000 + 50 * (18 + i - 1800)); /// Грешка в сметките и са нужни скоби
  31. //// totalExpences = totalExpences + (12000 + 50 * (i + ivanchosYears));// cъс твоята променлива само, че написана вярно
  32. }
  33. }
  34.  
  35.  
  36.  
  37. if (totalExpences > money)
  38. {
  39. double restMoney = totalExpences - money;
  40. Console.WriteLine("He will need {0:F2} dollars to survive.", restMoney); // Грешка няма закръгляне
  41.  
  42. }
  43. else if (totalExpences <= money) /// грешка трябва да има и равно и да се опише
  44. {
  45. double restMoney = money - totalExpences;
  46.  
  47. Console.WriteLine("Yes! He will live a carefree life and will have {0:F2} dollars left.", restMoney);// Грешка няма закръгляне
  48. }
  49.  
  50.  
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement