Advertisement
dsavov_02

оценки

Feb 2nd, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 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. for (int i = 0;i<ocenki.Length; i++)
  12. {
  13. Console.Write("Въведи оценка: ");
  14. ocenki[i]= double.Parse(Console.ReadLine());
  15. }
  16.  
  17. double sum = 0;
  18. int invalid = 0;
  19. int valid = 0;
  20. for (int i = 0;i<ocenki.Length; i++)
  21. {
  22. if (ocenki[i] < 2 || ocenki[i] > 6)
  23. {
  24. invalid++;
  25. }
  26. else
  27. {
  28. valid++;
  29. }
  30. sum += ocenki[i];
  31. }
  32. double avg = sum / ocenki.Length;
  33. Console.WriteLine("Невалидни оценки: {0} ", invalid);
  34. Console.WriteLine("Валидни оценки: {0}", valid);
  35. Console.WriteLine("Среден успех: {0:F2}", avg);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement