Advertisement
EmoRz

Back to the Past

Jul 17th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. namespace backToThePast
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var money = double.Parse(Console.ReadLine());
  10.             var year = int.Parse(Console.ReadLine());
  11.             var startYear = 18;
  12.             var constant = 12000;
  13.             var calc = 0.0;
  14.  
  15.             for (int i = 1800; i <= year; i++)
  16.             {
  17.                 startYear++;
  18.                 if (i%2==0)
  19.                 {
  20.                     money -= constant;
  21.                 }
  22.                 else
  23.                 {
  24.                     if (startYear%2==0)
  25.                     {
  26.                         startYear--;
  27.                     }
  28.                     calc = (startYear * 50) + constant;
  29.                     money -= calc;
  30.                 }
  31.             }
  32.             if (money>=0)
  33.             {
  34.                 Console.Write("Yes!");
  35.                 Console.WriteLine($" He will live a carefree life and will have {money:f2} dollars left.");
  36.             }
  37.             else
  38.             {
  39.                 var plusExchange = Math.Abs(money);
  40.                 Console.WriteLine($"He will need {plusExchange:f2} dollars to survive.");
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement