Advertisement
Guest User

Untitled

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