tsvetelinapasheva

BackToThePast

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