Advertisement
Guest User

Untitled

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