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

Write a program to do the following. In main declare a Player Name Array and a S

ID: 3624797 • Letter: W

Question

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 function input the player name and score into the arrays for an unknown number of players up to 100. In the DisplayPlayerData function display the name and score of each player. In the CalculateAverageScore function calculate the average score and return it by value. In the DisplayBelowAverage function 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 pseudo code below, write the code that will meet the requirements:

Main Function
Declare the player name and score arrays, number of players, and average score.

Call the InputData function
Call the DisplayPlayerData function
Call the CalculateAverageScore function and assign the returned value in average score
Call the DisplayBelowAverage function

InputData function
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 function
Display the name and score of each player

CalculateAverageScore function
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 function
Display the names and scores of all players who scored below the average score

Explanation / Answer

please rate-thanks

#include <iostream>
using namespace std;
void inputData(int[],string[],int&);
void displayPlayerData(int[],string[],int);
double calculateAverageScore(int[],int);
void displayBelowAverage(int[],string[],int,double);
int main()
{int score[100];
double average;
string name[100];
int n=0;
inputData(score,name,n);
displayPlayerData(score,name,n);
average=calculateAverageScore(score,n);
displayBelowAverage(score,name,n,average);
system("pause");
return 0;
}
void inputData(int score[],string name[],int& n)
{cout<<"Enter Player Name (Q to quit): ";
cin>>name[n];
while(name[n].compare("Q")!=0)
    {cout<<"Enter score for "<<name[n]<<": ";
    cin>>score[n];
    n++;
    cout<<"Enter Player Name (Q to quit): ";
    cin>>name[n];
}
}
void displayPlayerData(int score[],string name[],int n)
{int i;
cout<<" Name Score ";
for(i=0;i<n;i++)
     cout<<name[i]<<" "<<score[i]<<endl;
}
double calculateAverageScore(int score[],int n)
{double a,sum=0;
int i;
for(i=0;i<n;i++)
     sum+=score[i];
a=sum/n;
cout<<" Average Score: "<<a<<endl;
return a;
       }
void displayBelowAverage(int score[],string name[],int n,double average)
{int i;
cout<<" Players who scored below average Name Score ";
for(i=0;i<n;i++)
      if(score[i]<average)
           cout<<name[i]<<" "<<score[i]<<endl;
}

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