Advertisement
demirman

Untitled

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