Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in C#, to help instructors calculate grades for students. You fi

ID: 3859191 • Letter: W

Question

Write a program in C#, to help instructors calculate grades for students. You first want to prompt instructors to enter the desired number of scores. This value is the size of your array (you can use an array of type int for this assignment). Then, use a loop to prompt the instructors to enter the scores (from 0 to 100). You must store each score in this array. Once the users have entered all scores, use a loop to calculate the grade for each student in the course and the corresponding letter grade. Output the final grade and corresponding letter grade. You may assume that the instructor enters each score, and that all scores are weighted the same. Make sure to run through your program a few times to ensure that it works properly.

Explanation / Answer

using System;

public class Test

{

public static void Main()

{

Console.WriteLine("Enter the number of scores : ");

int size = Convert.ToInt32(Console.ReadLine());

int sum = 0;

string letterGrade;

int grade;

int [] scores = new int[size]; /* arr is an array of size integers */

int i,j;

/* Enter the scores */

for ( i = 0; i < size; i++ )

{

Console.WriteLine("Enter the score(0-100) : ");

scores[i] = Convert.ToInt32(Console.ReadLine());

}

/* calculate grade */

for ( i = 0; i < size; i++ )

{

sum = sum + scores[i];

}

grade = sum/size;

if(grade >80 && grade <=100)

{

letterGrade = "A";

}

else if(grade >60 && grade <=80)

{

letterGrade = "B";

}

else if(grade >40 && grade <=60)

{

letterGrade = "C";

}

else if(grade >0 && grade <=40)

{

letterGrade = "F";

}

else

letterGrade = "Invalid";

Console.WriteLine(" The grade of the student is "+ letterGrade + " and percentage is "+grade);

Console.ReadKey();

}

}

Output:

Enter the number of scores : 5
Enter the score(0-100) : 87
Enter the score(0-100) : 67
Enter the score(0-100) : 91
Enter the score(0-100) : 76
Enter the score(0-100) : 65

The grade of the student is B and percentage is 77

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote