Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Back_To_The_Past
- {
- class back_past
- {
- static void Main(string[] args)
- {
- double money = double.Parse(Console.ReadLine());
- int year = int.Parse(Console.ReadLine());
- ///int ivanchosYears = -1782; //// няма нужда от тази променлива, сметната беше грешно, ако искаш да използваш използвай тази
- double totalExpences = 0;
- for (int i = 1800; i <= year; i++)
- {
- if (i % 2 == 0)
- {
- totalExpences += 12000;
- }
- else if (i % 2 != 0)
- {
- totalExpences = totalExpences + (12000 + 50 * (18 + i - 1800)); /// Грешка в сметките и са нужни скоби
- //// totalExpences = totalExpences + (12000 + 50 * (i + ivanchosYears));// cъс твоята променлива само, че написана вярно
- }
- }
- if (totalExpences > money)
- {
- double restMoney = totalExpences - money;
- Console.WriteLine("He will need {0:F2} dollars to survive.", restMoney); // Грешка няма закръгляне
- }
- else if (totalExpences <= money) /// грешка трябва да има и равно и да се опише
- {
- double restMoney = money - totalExpences;
- Console.WriteLine("Yes! He will live a carefree life and will have {0:F2} dollars left.", restMoney);// Грешка няма закръгляне
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement