Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Grades
- {
- class Program
- {
- static void Main(string[] args)
- {
- int students = int.Parse(Console.ReadLine());
- double p1 = 0;
- double p2 = 0;
- double p3 = 0;
- double p4 = 0;
- double p1Percent = 0;
- double p2Percent = 0;
- double p3Percent = 0;
- double p4Percent = 0;
- double totalGrade = 0;
- for (int i = 0; i < students; i++)
- {
- double grade = double.Parse(Console.ReadLine());
- if (grade < 3)
- {
- p1++;
- }
- else if (grade < 4)
- {
- p2++;
- }
- else if (grade < 5)
- {
- p3++;
- }
- else
- {
- p4++;
- }
- totalGrade+= grade;
- p1Percent = p1 / students * 100;
- p2Percent = p2 / students * 100;
- p3Percent = p3 / students * 100;
- p4Percent = p4 / students * 100;
- }
- double average = 0;
- average = totalGrade / students;
- Console.WriteLine($"Top students: {p4Percent:f2}%");
- Console.WriteLine($"Between 4.00 and 4.99: {p3Percent:f2}%");
- Console.WriteLine($"Between 3.00 and 3.99: {p2Percent:f2}% ");
- Console.WriteLine($"Fail: { p1Percent:f2}%");
- Console.WriteLine($"Average: {average:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment