Guest User

Untitled

a guest
Feb 3rd, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 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.  
  12.         for (int i = 0; i <= difference; i++)
  13.         {
  14.             if (i % 2 == 0)
  15.             {
  16.                 Money = Money - 12000;
  17.             }
  18.             else
  19.             {
  20.                 Money = Money - (12000 + (50 * age));
  21.  
  22.             }
  23.             age++;
  24.         }
  25.        
  26.         if (Money >= 0)
  27.         {
  28.             Console.WriteLine("Yes! He will live a carefree life and will have {0:F2} dollars left.", Money);
  29.         }
  30.         else
  31.         {
  32.             Console.WriteLine("He will need {0:F2} dollars to survive.", Math.Abs(Money));
  33.         }
  34.         Console.ReadLine();
  35.  
  36.     }
  37. }
Add Comment
Please, Sign In to add comment