Advertisement
donsavage

Account Balance

Nov 5th, 2018
1,329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 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 _06.Account_Balance
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int N = int.Parse(Console.ReadLine());
  14.             int S = 0;
  15.             double B = 0.0;
  16.  
  17.             while (S < N)
  18.             {
  19.                 double T = double.Parse(Console.ReadLine());
  20.                 if (T < 0)
  21.                 {
  22.                     Console.WriteLine("Invalid operation!");
  23.                     break;
  24.  
  25.                 }
  26.                 else
  27.                 {
  28.                     B += T;
  29.                     Console.WriteLine($"Increase: {T:F2}");
  30.                 }
  31.                 S++;
  32.  
  33.             }
  34.             Console.WriteLine($"Total: {B:F2}");
  35.  
  36.         }
  37.     }
  38. }
  39.  
  40. /*
  41. --- Var Legend
  42.  
  43. N = Number
  44. S = Sumer
  45. B = Balance
  46. T = Total
  47.  
  48. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement