knikolov98

Untitled

Sep 25th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 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 BankAccount
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int transactionCount = int.Parse(Console.ReadLine());
  15.            
  16.             int counter = 1;
  17.             double totalAmount = 0.0;
  18.  
  19.  
  20.  
  21.             while (counter <= transactionCount)
  22.  
  23.             {
  24.                 double transactionAmount = double.Parse(Console.ReadLine());
  25.  
  26.                 if (transactionAmount < 0)
  27.                 {
  28.                     Console.WriteLine("Invalid operation!");
  29.                     break;
  30.                 }
  31.  
  32.                 Console.WriteLine($"Increase: {transactionAmount:f2}");
  33.                 totalAmount += transactionAmount;
  34.                 counter++;
  35.             }
  36.             Console.WriteLine($"Total: {totalAmount:f2}");
  37.  
  38.  
  39.  
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment