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 Lab1_7
- {
- class Program
- {
- /*
- ** author: Damjan Miloshevski
- ** contact: d.miloshevski@gmail.com;
- ** skype: damjan.milosevski
- ** phone: +38978566409;
- ** web: https://www.facebook.com/damjan.miloshevski
- http://miloshevski.us.to/
- */
- static void Main(string[] args)
- {
- Console.WriteLine(" ------ PROGRAMA ZA BROEVI. LABORATORISKA 1 - VIZUELNO PROGRAMIRANJE ------ ");
- Console.WriteLine();
- Console.WriteLine("Izberi:");
- Console.WriteLine();
- Console.WriteLine("0 - Vnesi broevi racno");
- Console.WriteLine();
- Console.WriteLine("1 - Generiraj avtomatski");
- Console.WriteLine();
- Console.WriteLine("2 - Izlezi");
- Console.WriteLine();
- Console.Write("Vasiot izbor: ");
- int input = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine();
- switch (input)
- {
- case 0:
- {
- Console.WriteLine("------ RACNO VNESUVANJE ------ ");
- Console.WriteLine();
- Console.Write("Kolku broevi kje vnesete: ");
- int max = int.MinValue;
- int min = int.MaxValue;
- double sum = 0;
- double avg = 0;
- int n = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine();
- Console.WriteLine("Vnesete gi vashite broevi:");
- Console.WriteLine();
- for (int i = 1; i <= n; i++)
- {
- Console.WriteLine("Broj {0}: ", i);
- int broj = Convert.ToInt32(Console.ReadLine());
- sum += broj;
- avg = sum / n;
- if (broj > max)
- {
- max = broj;
- }
- if (broj < min)
- {
- min = broj;
- }
- }
- Console.WriteLine();
- Console.WriteLine(string.Format("Suma = {0:#.##}, Prosek = {1:#.##} , Minimum = {2}, Maximum = {3}", sum, avg, min, max));
- Console.WriteLine();
- Console.WriteLine("Pritisnete bilo koe kopce da izlezete");
- break;
- }
- case 1:
- {
- Console.WriteLine("------ AVTOMATSKO GENERIRANJE ------");
- Random n = new Random();
- int max = int.MinValue;
- int min = int.MaxValue;
- double sum = 0;
- double avg = 0;
- for (int i = 1; i < 1001; i++)
- {
- int vrednost = n.Next(1, 1000);
- sum += vrednost;
- avg = sum / 1000;
- if (vrednost > max)
- {
- max = vrednost;
- }
- if (vrednost < min)
- {
- min = vrednost;
- }
- }
- Console.WriteLine();
- Console.WriteLine(string.Format("Suma = {0:#.##}, Prosek = {1:#.##} , Minimum = {2}, Maximum = {3}", sum, avg, min, max));
- Console.WriteLine();
- Console.WriteLine("Pritisnete bilo koe kopce da izlezete");
- break;
- }
- case 2:
- {
- Console.WriteLine("------ IZLEZ ------");
- Console.WriteLine();
- Console.WriteLine("Se otkazuvate :(. Izbravte izlez. Programata sega kje zavrshi.\nPritisnete bilo koe kopce za da izlezete.");
- break;
- }
- default:
- Console.WriteLine("Nevaliden izbor. Programata sega kje zavrshi.");
- break;
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement