Advertisement
desislava_topuzakova

05. ACCOUNT BALANCE

Jul 2nd, 2022
1,153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace P05
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double bankAccount = 0.0;
  10.             string input = Console.ReadLine();
  11.  
  12.             while(input != "NoMoreMoney")
  13.             {
  14.                 double increaseSum = double.Parse(input);
  15.                 if (increaseSum < 0)
  16.                 {
  17.                     Console.WriteLine("Invalid operation!");
  18.                     break;
  19.                 }
  20.                 bankAccount += increaseSum;
  21.                 Console.WriteLine($"Increase: {increaseSum:F2}");
  22.                 input = Console.ReadLine();
  23.             }
  24.             Console.WriteLine($"Total: {bankAccount:F2}");
  25.         }
  26.     }
  27. }
Advertisement
RAW Paste Data Copied
Advertisement