Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace RajakKlase
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = new List<int>();
- bool stayInLoop = true;
- string unosKorisnika;
- int unetiBroj;
- do
- {
- Console.Write("Unesite broj (ostavi prazno za zavrsetak): ");
- unosKorisnika = Console.ReadLine();
- if (string.IsNullOrEmpty(unosKorisnika))
- {
- break;
- }
- unetiBroj = Convert.ToInt32(unosKorisnika);
- numbers.Add(unetiBroj);
- } while (stayInLoop);
- Console.WriteLine("Suma svih brojeva je {0}", Suma.CalculateSum(numbers));
- Console.ReadKey();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace RajakKlase
- {
- class Suma
- {
- public static int CalculateSum(List<int> numbers)
- {
- int brojac = 0;
- foreach (int number in numbers)
- {
- brojac += number;
- }
- return brojac;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement