Advertisement
desislava_topuzakova

05. Account Balance

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