grach

2016_July_17_2016 Back to the past

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