Advertisement
dragonbs

Account Balance

Oct 23rd, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.AccountBalance
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string input = Console.ReadLine();
  10.             double totalSum = 0;
  11.  
  12.             while (input != "NoMoreMoney")
  13.             {
  14.                 double moneyIncrease = double.Parse(input);
  15.                 if (moneyIncrease < 0)
  16.                 {
  17.                     Console.WriteLine("Invalid operation!");
  18.                     break;
  19.                 }
  20.  
  21.                 Console.WriteLine($"Increase: {moneyIncrease:f2}");
  22.                 totalSum += moneyIncrease;
  23.  
  24.                 input = Console.ReadLine();
  25.             }
  26.             Console.WriteLine($"Total: {totalSum:f2}");
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement