Advertisement
fbinnzhivko

Untitled

Jul 18th, 2016
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2. class Example
  3. {
  4.     public static void Main()
  5.     {
  6.         double Money = double.Parse(Console.ReadLine());
  7.         int year = int.Parse(Console.ReadLine());
  8.         int age = 18;
  9.         int difference = year - 1800;
  10.  
  11.         for (int i = 0; i <= difference; 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.         if (Money >= 0)
  24.         {
  25.             Console.WriteLine("Yes! He will live a carefree life and will have {0:F2} dollars left.", Money);
  26.         }
  27.         else
  28.         {
  29.             Console.WriteLine("He will need {0:F2} dollars to survive.", Math.Abs(Money));
  30.         }    
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement