Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace For_Loop___More_Exercises
- {
- class Program
- {
- static void Main(string[] args)
- {
- double age = 18;
- double money = double.Parse(Console.ReadLine());
- int yearToLive = int.Parse(Console.ReadLine());
- for (int year = 1800; year <= yearToLive; year++)
- {
- if (year % 2 == 0)
- {
- money = money - 12000;
- }
- else if (year % 2 != 0)
- {
- money = money - (12000 + (50 * age));
- }
- }
- if (money >= 0)
- {
- Console.WriteLine($"Yes! He will live a carefree life and will have {Math.Abs(money):f2} dollars left.");
- }
- else
- {
- Console.WriteLine($"He will need {money:f2} dollars to survive.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement