Write a program to do the following: In main, declare a Player Name Array and a Score Array. Declare the size of the arrays to be 100. In the InputData( ) method, input the player name and score into the arrays for an unknown number of players up to 100. In the DisplayPlayerData method, display the name and score of each player. In the CalculateAverageScore( ) method, calculate the average score and return it by value. In the DisplayBelowAverage( ) method, display the name of the player and score for any player who scored below the average. Do not use global variables.
Output from Program:
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 . . .
Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements:
Main Method
Declare the player name and score arrays, number of players,
and average score.
Call the InputData( ) method
Call the DisplayPlayerData( ) method
Call the CalculateAverageScore( ) method and assign the returned value in average score
Call the DisplayBelowAverage( ) method
InputData method
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
End-While
DisplayPlayerData method
Display the name and score of each player
CalculateAverageScore method
Add up the scores and divide by the number of scores to calculate the average score
Display the average score
Return the average score to main
DisplayBelowAverage method
Display the names and scores of all players who scored below the average score
Step 3: Create a new project
Create a new project and name it LAB5A.
Write your code using the Processing Logic in Part A Step 2. Make sure you save your program.
Step 4: Compile and Execute
a) Compile your program. Eliminate all syntax errors.
b) Build your program and verify the results of the program. Make corrections to the program logic if necessary until the results of the program execution are what you expect.
1 answer
The project requires knowledge of input/output, simple calculations, and simple program flow.
You will need to review the above topics either from your textbook or from your teacher's notes. Review examples. Try to come up with a pseudocode or some actual coding.
We will be glad to help you debug if necessary, or correct syntax or logical errors whichever the case may be.