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 BackToThePast_02
- {
- class Program
- {
- static void Main(string[] args)
- {
- // define and read input variables ................................
- double money = double.Parse(Console.ReadLine());
- int year = int.Parse(Console.ReadLine());
- // define and calc calculated variables ...........................
- int startYear = 1800;
- double moneyEvenYear = 0.00;
- double moneyOddYear = 0.00;
- double moneyLeft = 0.00;
- // LOGIC nad CALC =================================================
- // calc even and odd money.........................................
- for( int i = startYear; i <= year; i++)
- {
- if(i % 2 == 0) // even year
- {
- moneyEvenYear = moneyEvenYear + 12000;
- }
- else // odd year
- {
- moneyOddYear = moneyOddYear + 12000 + (50 * (18 + i - startYear));
- }
- }
- moneyLeft = (money - ( moneyEvenYear + moneyOddYear ));
- // calc money left ................................................
- if (moneyLeft > 0)
- {
- Console.WriteLine($"Yes! He will live a carefree life and will have {moneyLeft:f2} dollars left.");
- }
- else
- {
- Console.WriteLine($"He will need {Math.Abs(moneyLeft):f2} dollars to survive.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement