Advertisement
NadyaMisheva

ocenki validni

Feb 2nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         Console.WriteLine("Избери брой оценки: ");
  8.         int n = int.Parse(Console.ReadLine());
  9.        
  10.         double[] ocenki = new double[n];
  11.         ////////////////////////////////////////////////////////////////
  12.        
  13.         for(int i = 0; i < ocenki.Length; i++)
  14.         {
  15.             Console.WriteLine("Въведи оценка {0}", i);
  16.             ocenki[i] = double.Parse(Console.ReadLine());
  17.            
  18.         }
  19.        
  20.         double sym = 0;
  21.        
  22.         int Vchisla = 0;   
  23.         for(int i = 0; i < ocenki.Length; i++)
  24.         {
  25.            
  26.            
  27.             if (ocenki[i] <= 6 && ocenki[i] >= 2)
  28.             {
  29.                 Vchisla ++;
  30.                 sym += ocenki[i];
  31.             }
  32.         }
  33.        
  34.         double avg = sym / Vchisla;
  35.         Console.WriteLine( "Невалидни оценки : {0}", n - Vchisla);
  36.         Console.WriteLine( "Валидни оценки : {0}", Vchisla);
  37.         Console.WriteLine("Средният успех е {0:f2}", avg);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement