Advertisement
Dianov

While Loop - Lab (05. Account Balance)

Dec 29th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 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 AccountBalance
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string sum = Console.ReadLine();
  14.             double total = 0;
  15.             while (sum != "NoMoreMoney")
  16.             {
  17.                 if (double.Parse(sum) < 0)
  18.                 {
  19.                     Console.WriteLine("Invalid operation!");
  20.                     break;
  21.                 }
  22.                 Console.WriteLine($"Increase: {double.Parse(sum):F2}");
  23.                 total += double.Parse(sum);
  24.                 sum = Console.ReadLine();
  25.             }
  26.             Console.WriteLine($"Total: {total:F2}");
  27.         }  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement