Advertisement
silvana1303

back to the past

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