Advertisement
MARINA_GREBENAROVA

Account_Balance

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