Advertisement
dsavov_02

TRIP IN THE PAST

Dec 5th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         double money = double.Parse(Console.ReadLine());
  8.         int year = int.Parse(Console.ReadLine());
  9.         int age = 18;
  10.        
  11.         for (int yearnow = 1800; yearnow <= year; yearnow++)
  12.         {
  13.             if (yearnow % 2 == 0)
  14.             {
  15.                 money -= 12000;
  16.             }
  17.             else
  18.             {
  19.                 money -= 12000+ 50 * age;
  20.             }
  21.             age++;
  22.         }
  23.         if (money > 0)
  24.         {
  25.             Console.WriteLine ("Yes! He will live a carefree life and will have {0:F2} dollars left.", money);
  26.         }
  27.         else
  28.         {
  29.             Console.WriteLine ("He will need {0:F2} dollars to survive.", Math.Abs(money));
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement