Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _01.Students
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("How many students?");
- int n = int.Parse(Console.ReadLine());
- double[] grades = new double[n];
- int[] failed = new int[n];
- int sreden = 0, good = 0, verygood = 0, excelent = 0;
- double averageGrade = 0;
- int j = 0;
- for (int i = 0; i < n; i++)
- {
- grades[i] = double.Parse(Console.ReadLine());
- while (grades[i] < 2 || grades[i] > 6)
- {
- Console.WriteLine("Greshna ocenka. Napishi nova: ");
- grades[i] = double.Parse(Console.ReadLine());
- }
- if (grades[i] == 2)
- {
- failed[j] = i + 1;
- j++;
- }
- switch (grades[i])
- {
- case 3:
- sreden++;
- break;
- case 4:
- good++;
- break;
- case 5:
- verygood++;
- break;
- case 6:
- excelent++;
- break;
- }
- averageGrade += grades[i];
- }
- averageGrade /= n;
- Console.Write("Nomera na uchenici sus slab 2: ");
- for (int i = 0; i < n; i++)
- {
- if (failed[i] == 0)
- {
- break;
- }
- Console.Write(failed[i] + " ");
- }
- Console.WriteLine();
- Console.WriteLine($"Average grade is: {averageGrade:F2}");
- Console.WriteLine($"Broi na uchenici s 2: {failed.Count(g => g != 0)}");
- Console.WriteLine($"Broi na uchenici s 3: {sreden}");
- Console.WriteLine($"Broi na uchenici s 4: {good}");
- Console.WriteLine($"Broi na uchenici s 5: {verygood}");
- Console.WriteLine($"Broi na uchenici s 6: {excelent}");
- }
- }
- }
Add Comment
Please, Sign In to add comment