anizko

sumBallance - edit

Apr 9th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 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. using System;
  8.  
  9. namespace sumBallance
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             int totalDepositCount = int.Parse(Console.ReadLine());
  16.             int depositCounter = 0;//int depositCounter = int.Parse(Console.ReadLine());
  17.             double sum = 0.0;
  18.  
  19.  
  20.             while (depositCounter < totalDepositCount)
  21.             {
  22.                 double deposit = double.Parse(Console.ReadLine());
  23.  
  24.                 if (deposit > 0)//в сумата sum, не трябва да влизат отрицателните суми, затовa я отделяме с if-else
  25.                 {
  26.                     Console.WriteLine($"Increase: {deposit:f2}");//Console.WriteLine($"Increase: {sum: F2}");
  27.                     sum += deposit;
  28.                     depositCounter++;
  29.                 }
  30.  
  31.                 else
  32.                 {
  33.                     Console.WriteLine("Invalid operation!");
  34.                     break;
  35.                 }
  36.             }
  37.  
  38.  
  39.             Console.WriteLine($"Total: {sum:F2}");
  40.  
  41.  
  42.  
  43.         }
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment