Advertisement
koksibg

Back_To_The_Past

Feb 10th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Back_To_The_Past
  8. {
  9.     class Back_To_The_Past
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double Money = double.Parse(Console.ReadLine());
  14.             int Year = int.Parse(Console.ReadLine());
  15.             int AgesNow = 18;
  16.             for (int i = 0; i <= Year - 1800; i++)
  17.             {
  18.                 if (i % 2 == 0)
  19.                 {
  20.                     Money -= 12000;
  21.                 }
  22.                 else
  23.                 {
  24.                     Money -= 12000 + 50 * AgesNow;
  25.                 }
  26.                 AgesNow++;
  27.             }
  28.             if (Money >= 0) Console.WriteLine("Yes! He will live a carefree life and will have {0:f2} dollars left.", Money);
  29.             else 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