Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n; // number of pupils in the class
- int g; // pupil grade
- int sum; // sum of pupils grades
- double avg; // average of grades
- int max; // maximum pupil grade
- int min; // minimum pupil grade
- int[] grades; // array of pupils grades
- Console.Write("Enter the number of pupils: ");
- n = int.Parse(Console.ReadLine());
- sum = 0;
- max = 0;
- min = 100;
- grades = new int[n];
- for (int i = 0; i < n; i++)
- {
- Console.Write("Enter grade: ");
- g = int.Parse(Console.ReadLine());
- sum = sum + g;
- if (g > max)
- {
- max = g;
- }
- if (g < min)
- {
- min = g;
- }
- grades[i] = g;
- }
- avg = (10 * sum / n) / 10.0;
- //avg = 1.0*sum / n;
- Console.WriteLine("The grades average is " + avg);
- //Console.WriteLine("The grades average is {0}", avg);
- Console.WriteLine("maximum grade is {0}", max);
- Console.WriteLine("minimum grade is {0}", min);
- int c = 0;
- int cmin = 0;
- for (int i = 0; i < n; i++)
- {
- if (grades[i] > avg)
- {
- c++;
- }
- if (grades[i] < avg)
- {
- cmin++;
- }
- }
- Console.WriteLine("{0} pupils have grade greater than the average {1}", c, avg);
- Console.WriteLine("{0} pupils have grade lower than the average {1}", cmin, avg);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement