Design and implement a program that computes final averages for a set of grades. The program reads the grades from a user. (10) The format of a grade line is: N grades1, grades2, …………., grades5 Where N is total number of students and grades is the ith score. All scores must be between 0 and 100. The program reads the grades from the user, calculate and display the average
The weighted average is computed as:
NB: Your program should validate its input. That is, it should make sure each score is between 0 and 100 and that each student has n scores/ grades. If a student’s grades are invalid, the program should display an error message. The program should contain modules / functions that handles validating the input
static void Main(string[] args)
{
int grade;
string name;
string[] arr = new string[10];
for (int j = 0; j < 10; j++)
{
Console.WriteLine("Enter name student:");
name = Console.ReadLine();
for (int i = 0; i < arr.Length; i++)
{
grade = int.Parse(Console.ReadLine());
if (grade >= 0 && grade < 101)
{
}
else
{
Console.WriteLine("Error");
break;
}
}
}
}
Comments
Leave a comment