Advertisement
drunin89

04. Back To The Past

Nov 13th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 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 BackToThePast
  8. {
  9.     class BackToThePast
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var money = double.Parse(Console.ReadLine());
  14.             var year = int.Parse(Console.ReadLine());
  15.             double result = money;
  16.                 for (int i = 1800; i <= year; i+=2)
  17.                 {
  18.                     result -= 12000;
  19.                 }
  20.                 for (int i = 1801; i <= year; i+=2)
  21.                 {
  22.                     result -= (12000 + (50 * (i - 1800 + 18)));
  23.                 }
  24.             if (result >= 0)
  25.             {
  26.                 Console.WriteLine("Yes! He will live a carefree life and will have {0:F2} dollars left.", result);
  27.             }
  28.             else if (result < 0)
  29.             {
  30.                 Console.WriteLine("He will need {0:F2} dollars to survive.", Math.Abs(result));
  31.             }
  32.             else
  33.             {
  34.             }
  35.  
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement