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 Program
- {
- static void Main(string[] args)
- {
- double moneyHeritage = double.Parse(Console.ReadLine());
- int year = int.Parse(Console.ReadLine());
- double moneySpent = 0.0;
- for (int i = 1800; i <= year; i++)
- {
- if (i % 2 == 0)
- {
- moneySpent += 12000;
- }
- else
- {
- moneySpent += 12000 + 50 * (i - 1800 + 18);
- }
- }
- if (moneyHeritage >= moneySpent)
- {
- Console.WriteLine("Yes! He will live a carefree life and will have {0:f2} dollars left.", moneyHeritage - moneySpent);
- }
- else
- {
- Console.WriteLine("He will need {0:f2} dollars to survive.", moneySpent - moneyHeritage);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment