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

Pseudocode: Main Function Declare player and score arrays, and variables for num

ID: 3629334 • Letter: P

Question

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

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

Name Score

Bob 3245

Sue 1098

Dave 8219

Pat 3217

Average Score: 3944.75

Players who scored below average

Name Score

Bob 3245

Sue 1098

Pat 3217

Press any key to continue . . .

Explanation / Answer

class Program { static void Main(string[] args) { string []playerName; double[] score; double avgScore; int numberOfPlayers=0; playerName=new string[100]; score=new double[100]; numberOfPlayers=InputData(playerName, score); DisplayPlayerData(playerName, score,numberOfPlayers); avgScore = CalculateAverageScore(score,numberOfPlayers); Console.WriteLine(" Average score: {0} ", avgScore); Console.WriteLine("Players who scored below average"); DisplayBelowAverage(playerName, score, avgScore,numberOfPlayers); Console.Write("Press any key to continue..."); Console.ReadKey(); } static int InputData(string []playerName,double []score) { int count = 0; do { Console.Write("Enter Player Name (Q to quit): "); playerName[count] = Console.ReadLine(); if (playerName[count][0] == 'Q') return count; Console.Write("Enter score for {0}: ", playerName[count]); score[count] = Convert.ToDouble(Console.ReadLine()); count++; } while (true); } static void DisplayPlayerData(string[] playerName, double[] score,int count) { Console.WriteLine(" Name Score"); for (int i = 0; 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