Advertisement
Rodunskiy

Untitled

Jun 4th, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. class program
  2. {
  3.     static void Main(string[] args)
  4.     {      
  5.         List<int> numbers = new List<int>();
  6.  
  7.         string sum = "sum";
  8.         string exit = "exit";
  9.         bool isWorking = true;
  10.  
  11.         while (isWorking)
  12.         {
  13.             string userInput = Console.ReadLine();
  14.  
  15.             if (userInput == sum)
  16.             {
  17.                 Console.WriteLine(numbers.Sum());
  18.             }
  19.             else if (userInput == exit)
  20.             {
  21.                 isWorking = false;
  22.             }
  23.             else
  24.             {
  25.                 numbers.Add(Convert.ToInt32(userInput));
  26.                 Console.Clear();
  27.             }
  28.         }
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement