using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Program { class Program { static void Main(string[] args) { Console.WriteLine("Program liczy średnią ocene"); int n,ile2=0, ile5=0; double oc, sr; Console.WriteLine("Wpisz ile ocen:"); while (!int.TryParse(Console.ReadLine(), out n) && n < 1) Console.WriteLine("Błędna wartość podaj jeszcze raz:"); double s = 0; Console.WriteLine("Podaj ilość ocen ucznia?"); for (int i = 1; i <= n; i++) { Console.Write("{0}:Ocena", i); while (!double.TryParse(Console.ReadLine(), out oc) || //oc < 2 || oc > 5) // /* jest źle*/ (oc !=2 && oc !=3 && oc !=3.5 && oc !=4 && oc !=4.5 && oc !=5) /*jest dobrze*/ !(oc == 2 || oc == 3 || oc == 3.5 || oc == 4 || oc == 4.5 || oc ==5) ) Console.WriteLine("Błędna wartość, podaj jeszcze raz: "); s = s + oc; if (oc == 2) ile2++; if (oc == 5) ile5++; } sr = s / n; Console.WriteLine("Średnia ocen to: {0}", sr); Console.WriteLine(" Ilość dwójek to {0}, ilość piątek to {1}", ile2, ile5); Console.ReadKey(); Console.WriteLine("Wciśnij dowolny klawisz"); } } }