Grimmjow1

BankAccount

Feb 2nd, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace AccountBalance
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int counter = 0;
  11.             double sum = 0;
  12.             while (counter<n)
  13.             {
  14.                 double income = double.Parse(Console.ReadLine());
  15.                 if (income<0)
  16.                 {
  17.                     Console.WriteLine("Invalid operation!");
  18.                     break;
  19.                 }
  20.                 Console.WriteLine($"Increase: {income:F2}");
  21.                 sum += income;
  22.                 counter++;
  23.             }
  24.             Console.WriteLine($"Total: {sum:F2}");
  25.  
  26.         }
  27.     }
  28. }
Add Comment
Please, Sign In to add comment