Advertisement
fbinnzhivko

Back To The Past

Jul 18th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2. class Example
  3. {
  4.     public static void Main()
  5.     {
  6.         decimal Money = decimal.Parse(Console.ReadLine());
  7.         int year = int.Parse(Console.ReadLine());
  8.         int age = 18;
  9.         int difference = year - 1800;
  10.  
  11.         for (int i = difference; i >= 0; i--)
  12.         {
  13.             if (i % 2 == 0)
  14.             {
  15.                 Money = Money - 12000;
  16.             }
  17.             else
  18.             {
  19.                 Money = Money - (12000 + (50 * age));
  20.             }
  21.             age++;
  22.         }
  23.  
  24.         if (Money >= 0)
  25.         {
  26.             Console.WriteLine("Yes! He will live a carefree life and will have {0:F2} dollars left.", Math.Abs(Money));
  27.         }
  28.         else
  29.         {
  30.             Console.WriteLine("He will need {0:F2} dollars to survive.", Math.Abs(Money));
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement