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

I need the text book solution for this C# excercise: Write a console program tha

ID: 3596625 • Letter: I

Question

I need the text book solution for this C# excercise:

Write a console program that uses an array to store a student’s scores on 5 quizzes.

Array:

1) An Integer array of 5 positions (1 position for each quiz score)

Methods:

GetScores: Allows the user to enter the scores on each of 5 quizzes.

FindAverage: Determines the average score by processing the arrays. Returns an average score (double).

ShowData: Displays the scores (with descriptive labels) and the average score.

Processing:

Program must implement the three methods and send the array to each method as an argument.

Explanation / Answer

using System;
class Quiz
{
public static void Main()
{
int[] a = new int[5];
GetScores(a);
showData(a);
}
//get scores method read scores from user and stores in array
public static void GetScores(int[] a){
Console.WriteLine("Enter the Array Elements ");
for (int i = 0; i < 5; i++){
a[i] = int.Parse(Console.ReadLine());
}
}
//FindAverage method calculates the average value of the array
public static double FindAverage(int[] a){
int sum = 0,avg=0;
for (int i = 0; i < 5; i++){
sum += a[i];
}
avg = sum / 5;
return avg;
}
//showData prints the output to the screen
public static void showData(int[] a){
Console.WriteLine("Quiz number Score");
for(int i=0;i<5;i++){
Console.WriteLine((i+1)+" "+a[i]);
}
Console.WriteLine("Average Score:"+FindAverage(a));
}
}

/*
sample output
Enter the Array Elements
1
3
5
7
9
Quiz number   Score
1       1
2       3
3       5
4       7
5       9
Average Score:5
*/

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