In: Computer Science
Using Visual Studio in C#; create a grading application for a class of ten students. The application should request the names of the students in the class. Students take three exams worth 100 points each in the class. The application should receive the grades for each student and calculate the student’s average exam grade. According to the average, the application should display the student’s name and the letter grade for the class using the grading scheme below. Grading Scheme: • A = 90-100 • B = 80-89 • C = 70-79 • D = 60-69 • F = <60
Create a C# console application with the name GradingApplication, add the below code in Program.cs
Program.cs
using System;
namespace GradingApplication
{
class Program
{
static void
Main(string[] args)
{
//variable declarations
string[] stuNames = new string[10];
double[,] stuGrades = new double[10, 3];
double[] stuAverage = new double[10];
double grade, sum, avg;
//run a loop that reads names and grade points of 10 students
for(int i = 0; i < stuNames.Length;i++)
{
//prompt and read student name
Console.Write("Enter the of student#" + (i + 1) + ": ");
stuNames[i] = Console.ReadLine();
//set sum to 0
sum = 0;
//run a loop to read grade points of three exams
for(int j = 0; j < 3;j++)
{
//prompt and read grade points received for each exam
Console.Write("Enter grade points received for exam #" + (j + 1) +
": ");
grade = Convert.ToDouble(Console.ReadLine());
//check if grade point entered is between 0 and 100
while (grade < 0 || grade > 100)
{
//if not within range display error message
Console.WriteLine("Error: Grade points must be between 0 and
100");
//reprompt for grade points received
Console.Write("Enter grade points received for exam #" + (j + 1) +
": ");
grade = Convert.ToDouble(Console.ReadLine());
}
stuGrades[i, j] = grade;
//add the grade to sum
sum = sum + grade;
}
avg = sum / 3.0;
stuAverage[i] = avg;
}
Console.WriteLine();
Console.WriteLine("Student Name\t\tLetter Grade Received");
//run a loop to get average of each student and determine the
letter grade received
for(int i = 0; i < stuAverage.Length; i++)
{
//display the student name
Console.Write(stuNames[i]+"\t\t\t");
//display A if average is between 100 and 90
if (stuAverage[i] >= 90 && stuAverage[i] <=
100)
Console.WriteLine("A");
//display B if average is between 80 and 89
else if (stuAverage[i] >= 80 && stuAverage[i] <=
89)
Console.WriteLine("B");
//display C if average is between 70 and 79
else if (stuAverage[i] >= 70 && stuAverage[i] <=
79)
Console.WriteLine("C");
//display D if average is between 60 and 69
else if (stuAverage[i] >= 60 && stuAverage[i] <=
69)
Console.WriteLine("D");
//else display F
else
Console.WriteLine("F");
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
}
}
Output:
Program Screenshot: