Anzzhhela98

lops

Jun 15th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BAck_to_the_PAst
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //вход от конзолта наследствени пари ->
  10.             double heritage = double.Parse(Console.ReadLine());
  11.            
  12.             int year = int.Parse(Console.ReadLine());
  13.             int difference = year-1800;
  14.             int age = 18;
  15.             //гонината до която ще живее вкл.
  16.  
  17.  
  18.             for (int i = 0; i <= difference; i++)
  19.             {
  20.                 // ако е четна ще харчи 12 000лв.
  21.                 if (i% 2 ==0)
  22.                 {
  23.                     heritage = heritage -12000;
  24.                 }
  25.                 // ако е нечетна  ще харчи 12 000 + 50-> по годините които е навършил през дадената година
  26.                 else
  27.                 {
  28.                    
  29.                     heritage = heritage - (12000+ (50 *age));
  30.                 }
  31.                 age++;
  32.             }
  33.             age++;
  34.             if (heritage >=0)
  35.             {
  36.                 Console.WriteLine("Yes! He will live a carefree life and will have {0:f2} dollars left.",heritage);
  37.             }
  38.             else
  39.             {
  40.                 Console.WriteLine("He will need {0:f2} dollars to survive.",Math.Abs (heritage));
  41.             }
  42.            
  43.             // дали парите които има ще стигнат за да живее
  44.            
  45.          
  46.         }
  47.     }
  48. }
Add Comment
Please, Sign In to add comment