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

C# Programming The application manages the quiz scores for a class of 3 students

ID: 3601782 • Letter: C

Question

C# Programming

The application manages the quiz scores for a class of 3 students. The user will specify how many quizzes each of the students has. The program should prompt the user to enter the names of each of the student as well as the quiz scores for each of the students.

It should then present the user with a menu system, which show a set of possible choices:

1) Calculate Class Average.
2) Calculate Student Average
3) Calculate Quiz Average

The program should prompt the user to enter a number corresponding with one of the choices, or the letter x to exit. As long as the user doesn’t press x, the program should keep showing the same menu to the user

CLASS AVERAGE - For the option to calculate class average, the program should calculate the average of all the quiz scores for all the students present. The program should then show the overall class average to the students.

STUDENT AVERAGE - The option to calculate student average should prompt the user for the name of the student. If the student is found in the list of names given earlier by the user, the program should calculate the average of the quiz scores for that student only and present them to the user. If the name is not found, it should present an error message to the user.

QUIZ AVERAGE - For the option to calculate quiz average, the program should prompt the user to enter a quiz number. It should then calculate the average for only that Quiz number. For example, assume that the user specified initially there would be 5 quizzes. If the user now specifies that he or she would like the average for Quiz 2. The program should then calculate the average of scores belonging to all students, however, considering only those scores specified for Quiz 2.

Sample Output-Detailed Example How nany scores per s tudent ter nane for student 1: Bethany tering scores for BETHANY Quiz 1: 78 Quiz 2: 89 Quiz 3: 91 Quiz 4: 92 Quiz 5: 95 ter name for student 2: Julius tering scores for JULIUS Quiz 1: 8 Quiz 2: 78 Quiz 3: 76 Quiz : 79 Quiz 5: 75 ter name for student 3: GEORGE tering scores for GEORGE Quiz 1: 62 Quiz 2: 70 Quiz 3: 75 Quiz 4: 69 Quiz 5 78 Menu Class Average 2. Student Average Quiz verage ter choice nunber or x to exit:

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Quiz
{
class Program
{
static void Main(string[] args)
{
char ch;
int choice,QuizNo;
int scores,k=1,sumAvgAll=0,countAvg=0,countQ=0,sumQ=0;
double classAvg,quizAvg;
string[] sname;
string name;
int[] studQuiz;
Console.Write("How many scores per student : ");
scores = Convert.ToInt32(Console.ReadLine());
studQuiz = new int[scores];
sname = new string [3];

for (int i = 0; i <= 2; i++,k++)
{
Console.Write("Enter name for student " + k + " : " + sname[i]);
sname[i] = Console.ReadLine();
Console.WriteLine("Entering scores for " + sname[i]);
for (int j = 0; j <scores; j++)
{
  
studQuiz[j] = Convert.ToInt32(Console.ReadLine() );
sumAvgAll = sumAvgAll + studQuiz[j];
countAvg = countAvg + 1;  
}
Console.WriteLine();
}

while (true)
{
Console.WriteLine(" Menu");
Console.WriteLine();
Console.WriteLine("1. Class Average 2. Student Average 3. Quiz Average");
Console.WriteLine("Enter your choice or 4 to exit : ");
choice =Convert.ToInt32 ( Console.ReadLine()) ;
switch (choice)
{
case 1:classAvg = (double)sumAvgAll / countAvg;
Console.WriteLine("Class Average for all quizzes is "+ Math.Round (classAvg,2) );
break;
case 2:Console.WriteLine("Calculating Average by Students : ");
Console.WriteLine("Enter Student name : ");
name = Console.ReadLine();
  
for (int i = 0; i <= 2; i++)
{

for (int j = 0; j < scores; j++)
{
if (name.Equals(sname[i]))
{
Console.Write(sname[i] + " scores are : "+studQuiz[j] );
  
}
else
{
Console.WriteLine("Student not found");
break;
}
}
  
  

  
Console.WriteLine();
}
break;

case 3:
Console.WriteLine("Calculating Average by Quiz number : ");
Console.WriteLine("Enter Quiz number: ");
QuizNo = Convert.ToInt32(Console.ReadLine() );
for (int i = 0; i <= 2; i++)
{
for (int j = 0; j < scores; j++)
{
if (QuizNo == j)
{
sumQ = sumQ + studQuiz[QuizNo];
countQ = countQ + 1;
}

}
  
}
quizAvg = (double)sumQ / countQ;
Console.WriteLine("Quiz " + QuizNo + " average is " + quizAvg);
break;

}
  
if (choice == 4 || choice == 4)
{
break;
}
}
Console.ReadKey();

}
}
}