Advertisement
DamSi

Untitled

Mar 6th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.67 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 Lab1_7
  8. {
  9.     class Program
  10.     {
  11.         /*
  12.           ** author: Damjan Miloshevski
  13.           ** contact: d.miloshevski@gmail.com;
  14.           ** skype: damjan.milosevski
  15.           ** phone: +38978566409;
  16.           ** web: https://www.facebook.com/damjan.miloshevski
  17.                   http://miloshevski.us.to/
  18.         */
  19.         static void Main(string[] args)
  20.         {
  21.             Console.WriteLine(" ------ PROGRAMA ZA BROEVI. LABORATORISKA 1 - VIZUELNO PROGRAMIRANJE ------ ");
  22.             Console.WriteLine();
  23.             Console.WriteLine("Izberi:");
  24.             Console.WriteLine();
  25.             Console.WriteLine("0 - Vnesi broevi racno");
  26.             Console.WriteLine();
  27.             Console.WriteLine("1 - Generiraj avtomatski");
  28.             Console.WriteLine();
  29.             Console.WriteLine("2 - Izlezi");
  30.             Console.WriteLine();
  31.             Console.Write("Vasiot izbor: ");
  32.             int input = Convert.ToInt32(Console.ReadLine());
  33.             Console.WriteLine();
  34.  
  35.             switch (input)
  36.             {
  37.                 case 0:
  38.                     {
  39.                         Console.WriteLine("------ RACNO VNESUVANJE ------ ");
  40.                         Console.WriteLine();
  41.                         Console.Write("Kolku broevi kje vnesete: ");
  42.                         int max = int.MinValue;
  43.                         int min = int.MaxValue;
  44.                         double sum = 0;
  45.                         double avg = 0;
  46.                         int n = Convert.ToInt32(Console.ReadLine());
  47.                         Console.WriteLine();
  48.                         Console.WriteLine("Vnesete gi vashite broevi:");
  49.                         Console.WriteLine();
  50.                         for (int i = 1; i <= n; i++)
  51.                         {
  52.                             Console.WriteLine("Broj {0}: ", i);
  53.                             int broj = Convert.ToInt32(Console.ReadLine());
  54.                             sum += broj;
  55.                             avg = sum / n;
  56.                             if (broj > max)
  57.                             {
  58.                                 max = broj;
  59.                             }
  60.                             if (broj < min)
  61.                             {
  62.                                 min = broj;
  63.                             }
  64.                         }
  65.                         Console.WriteLine();
  66.                         Console.WriteLine(string.Format("Suma = {0:#.##}, Prosek = {1:#.##} , Minimum = {2}, Maximum = {3}", sum, avg, min, max));
  67.                         Console.WriteLine();
  68.                         Console.WriteLine("Pritisnete bilo koe kopce da izlezete");
  69.                         break;
  70.                     }
  71.                 case 1:
  72.                     {
  73.                         Console.WriteLine("------ AVTOMATSKO GENERIRANJE ------");
  74.                         Random n = new Random();
  75.                         int max = int.MinValue;
  76.                         int min = int.MaxValue;
  77.                         double sum = 0;
  78.                         double avg = 0;
  79.                         for (int i = 1; i < 1001; i++)
  80.                         {
  81.                             int vrednost = n.Next(1, 1000);
  82.                             sum += vrednost;
  83.                             avg = sum / 1000;
  84.                             if (vrednost > max)
  85.                             {
  86.                                 max = vrednost;
  87.                             }
  88.                             if (vrednost < min)
  89.                             {
  90.                                 min = vrednost;
  91.                             }
  92.                         }
  93.                         Console.WriteLine();
  94.                         Console.WriteLine(string.Format("Suma = {0:#.##}, Prosek = {1:#.##} ,  Minimum = {2}, Maximum = {3}", sum, avg, min, max));
  95.                         Console.WriteLine();
  96.                         Console.WriteLine("Pritisnete bilo koe kopce da izlezete");
  97.                         break;
  98.                     }
  99.                 case 2:
  100.                     {
  101.                         Console.WriteLine("------ IZLEZ ------");
  102.                         Console.WriteLine();
  103.                         Console.WriteLine("Se otkazuvate :(. Izbravte izlez. Programata sega kje zavrshi.\nPritisnete bilo koe kopce za da izlezete.");
  104.                         break;
  105.                     }
  106.                 default:
  107.                     Console.WriteLine("Nevaliden izbor. Programata sega kje zavrshi.");
  108.                     break;
  109.             }
  110.             Console.ReadKey();
  111.         }
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement