Guest User

Untitled

a guest
Feb 3rd, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 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 _4.BackToThePast
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double heritage = double.Parse(Console.ReadLine());
  14.             int yearToLive = int.Parse(Console.ReadLine());
  15.        
  16.             double yearsold = 17;
  17.          
  18.             for (int year = 1800; year <= yearToLive; year++)
  19.             {
  20.                 if (year % 2 == 0)
  21.                 {
  22.                     heritage = heritage - 12000;
  23.  
  24.                 }
  25.                 else if(year % 2 != 0)
  26.                 {
  27.                     yearsold += 2;
  28.                     heritage = heritage - (12000 + (50 * yearsold));
  29.                    
  30.                 }
  31.                
  32.             }
  33.             if (heritage >= 0)
  34.             {
  35.                 Console.WriteLine("Yes! He will live a carefree life and will have {0:F2} dollars left.", heritage);
  36.             }
  37.             else
  38.             {
  39.                 Console.WriteLine("He will need {0:F2} dollars to survive.", Math.Abs(heritage));
  40.             }
  41.         }
  42.     }
  43. }
Add Comment
Please, Sign In to add comment