Advertisement
dimitrix85

Untitled

Dec 1st, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2.  
  3. namespace test123
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double total = double.Parse(Console.ReadLine());
  10.             double outgo = double.Parse(Console.ReadLine());
  11.             double mount = 0;
  12.             double sum = 0;
  13.  
  14.             while(true)
  15.             {
  16.                 if (sum >= total)
  17.                 {
  18.                     Console.WriteLine("You did it!");
  19.                     Console.WriteLine($"It took you {Math.Floor(mount / 12)} years {mount % 12} months");
  20.                     return;
  21.                 }
  22.  
  23.                 if (sum < 0)
  24.                 {
  25.                     Console.WriteLine("It seems you have bankrupted...");
  26.                     Console.WriteLine($"You have worked {Math.Floor(mount / 12)} years {mount % 12} months");
  27.                     return;
  28.                 }
  29.  
  30.                 double mountIncome = double.Parse(Console.ReadLine());
  31.                 sum += mountIncome - outgo;
  32.                 mount++;
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement