VanessaShopping

Exam 17 July

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