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

Need the following in C# using arrays Your mission : Write a program to determin

ID: 3684783 • Letter: N

Question

Need the following in C# using arrays

Your mission
: Write a program to determine statistics for a video game tournament. The user will input names and scores of all tournament players. The program will calculate the average score and display the players who scored below average.

The program will implement these functions:

Main(): Declares variables for the number of players and average score, and two arrays of size 100: one to store player names and the other to store their respective scores. Calls the following functions in sequence, passing necessary parameters by reference:

InputData( ): Gets player names and scores from the user and stores them into the two arrays for an unknown number of players up to 100.

DisplayPlayerData(): Displays each player's name and score.

CalculateAverageScore( ): Calculates the average score and returns it by value.

DisplayBelowAverage( ): Displays the names and scores of players who scored below average.

Sample output:

Enter Player Name (Q to quit): Bob

Enter score for Bob: 3245

Enter Player Name (Q to quit): Sue

Enter score for Sue: 1098

Enter Player Name (Q to quit): Dave

Enter score for Dave: 8219

Enter Player Name (Q to quit): Pat

Enter score for Pat: 3217

Enter Player Name (Q to quit): Q

I also need the program to follow the following pseudocode exactly:

Pseudocode

Main Function

Declare player and score arrays, and variables for number of players and average score.

Call the InputData( ) function, passing arrays and number of players variable by reference

Call the DisplayPlayerData( ) function, passing arrays and number of players variable by reference

Call the CalculateAverageScore( ) function, passing arrays and number of players by reference. Store returned value in average variable.

Display the average score

Call the DisplayBelowAverage( ) function, passing arrays and number of players variable by reference, passing average variable by value


InputData function

Loop while the number of players is less than the length of the array

Prompt for the player's name

If the user entered Q, break out of the loop

Prompt the user for the player's score

Add 1 to the number of players


DisplayPlayerData function

Loop to display the name and score of each player


CalculateAverageScore function

Loop to add up the scores

Divide by the number of players to calculate the average score

Return the average score to main


DisplayBelowAverage function

Loop to display the names and scores of all players who scored below the average score

Again, needed in C# thank you

Name Score Bob 3245 Sue 1098 Dave 8219 Pat 3217 Average Score: 3944.75 Players who scored below average

Explanation / Answer

namespace VidoeGame
{
class Prgm
{
static void Main(string[] args)
{
string[] playerName = new string[100];
int[] playerScore = new int[100];
int c = 0;
c=InputData(ref playerName, ref playerScore);
double avg= CalculateAverageScore(ref playerScore,c);
Console.WriteLine("Average Num:"+avg+" ");
Console.WriteLine("All Info");
DisplayPlayerData(ref playerName, ref playerScore, c);
Console.WriteLine();
Console.WriteLine("Below Average Info");
DisplayBelowAverage(avg, ref playerName, ref playerScore,c);
}
static int InputData(ref string[] player, ref int[] score)
{
int addName = 0,counter=0;
do
{
Console.Write("Enter Player's Name (Q to quit): ");
player[counter] = Console.ReadLine();
if (player[counter] == "q" || player[counter] == "Q")
{
addName = 1;
}
else
{
Console.Write("Enter score for {0}: ", player[counter]);
score[counter] = Convert.ToInt32(Console.ReadLine());
counter++;
}
}
while (addName != 1);
return counter;
}
static void DisplayPlayerData(ref string[] playerName, ref int[] playerScore,int counter)
{
for (int i = 0; i < counter; i++)
{
Console.WriteLine("Player Score ");
Console.WriteLine("***************");
Console.WriteLine("{0} {1}", playerName[i], playerScore[i]);
}
}
static double CalculateAverageScore(ref int[] playerScore,int counter)
{
int total = 0, avg = 0;
for (int i = 0; i < counter; ++i)
{
total += Convert.ToInt32(playerScore[i]);
}
if (playerScore.Length > 0)
avg = total / counter;
return avg;
}
static void DisplayBelowAverage(double avg, ref string[] playerName, ref int[] playerScore,int counter)
{
for (int i = 0; i < counter; i++)
{
if (playerScore[i] < avg)
{
Console.WriteLine("Player Score ");
Console.WriteLine("{0} {1}", playerName[i], playerScore[i]);
}
}
}
}
}

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