Facebook
From Cobalt Human, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 212
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Kraska04
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Program liczy średnią ocen, podaje ilość ocen 2, ilość ocen 5");
  14.             Console.WriteLine ("Autor: Jakub Kraska");
  15.             Console.WriteLine();
  16.  
  17.  
  18.              
  19.            
  20.            
  21.             Console.WriteLine("Podaj ilość ocen");
  22.             int i;
  23.             i = Convert.ToInt32(Console.ReadLine());
  24.             int[] o;
  25.             int x = 0, y = 0, sr = 0;
  26.             o = new int[i];
  27.             Console.WriteLine("Podaj oceny: ");
  28.             while (x<i)
  29.             {
  30.                 o[x] = Convert.ToInt32(Console.ReadLine());
  31.                 x++;
  32.             }
  33.             Console.WriteLine("Podaj element menu: \n1. Średnia ocen\n2. Ile razy występuje wybrana ocena\n3. Zakończenie programu");
  34.             int s;
  35.             s = Convert.ToInt32(Console.ReadLine());
  36.             switch (s)
  37.  
  38.             {
  39.                 case 1:
  40.                    
  41.                     x = 0;
  42.                     while (x<i)
  43.                     {
  44.                        
  45.  
  46.                         sr = sr+o[x];
  47.                         x++;
  48.                     }
  49.                     sr = sr / i;
  50.                     Console.WriteLine("Średnia wynosi: " + sr);
  51.                     break;
  52.                    
  53.                    
  54.                 case 2:
  55.                     Console.WriteLine("");
  56.                     break;
  57.                 case 3:
  58.                     Console.WriteLine("4");
  59.                     goto end;
  60.  
  61.                 default:
  62.                     Console.WriteLine("Ten numer MENU nie istnieje");
  63.                     break;
  64.                    
  65.  
  66.             }
  67.            
  68.           end:
  69.              
  70.             Console.ReadKey();
  71.  
  72.         }
  73.     }
  74. }
  75.