1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zhenek [66]
3 years ago
9

• Write a program to find the maximum, minimum, and average score of players. The input to the program is a file containing play

er name and his score. For maximum and minimum scores, your program needs to output the name of the players along with their scores. Use functions to calculate average, min, and max scores. • The text file will just have players name and scores • nbaStatsFN.txt Sample Input/Output Here’s how the output should look formatted as in first few names: Oladipo 23 Richardson 10 Beal 14 George 16 Lillard 24 James 37 Young 9 Antetokounmpo 25 Bogdanovic 18 McCollum 34 Lowry 11 Prince 28 Hill 17 Middleton 19 Young 22 Westbrook 23 Adams 18 Satoransky 9 Dragic 9 Rozier 33 Hardaway 11
Computers and Technology
1 answer:
Gekata [30.6K]3 years ago
6 0

Answer:

see explaination

Explanation:

#include<iostream>

#include<iomanip>

#include<fstream>

using namespace std;

int getMax(int[],int);

int getMin(int[],int);

double getAvg(int[],int);

const int NUM_PLAYERS = 50;

int main(){

//ARRAYS TO STORE ALL THE INFORMATION OF THE PLAYERS FROM THE FILE

string names[NUM_PLAYERS];

int points[NUM_PLAYERS];

int rebound[NUM_PLAYERS];

int age[NUM_PLAYERS];

int steals[NUM_PLAYERS];

int blocks[NUM_PLAYERS];

int pf[NUM_PLAYERS];

int b, maxIndex, minIndex;

//OPENING THE FILE TO READ THE STATS FROM

ifstream infile;

infile.open("nbastats.txt");

if(!infile){

cout<<"File cannot be opened, please try again.\n";

return -1;

}

string temp;

//STORE THE TABLE HEADER IN TEMP

getline(infile,temp);

int count = 0;

//ITERATE THROUGH THE LINES AS LONG AS WE CAN GET NAMES OF THE PLAYERS

while(infile >> names[count]){

infile>>age[count]>>points[count]>>rebound[count]>>steals[count]>>blocks[count]>>pf[count];

count++;

}

//DISPLAYING THE CONTENTS OF THE FILE IN THE SAME FORMAT AS IN THE FILE

cout<<temp<<endl;

for(int i=0;i<count;i++){

/*

THIS IS THE LINE WHICH DISPLAYS THE OUTPUT IN THE REQUIRED FORMAT

*/

cout<<left<<setw(16)<<names[i]<<setw(8)<<age[i]<<setw(8)<<points[i]<<setw(8)<<rebound[i]<<setw(8)<<steals[i]<<setw(8)<<blocks[i]<<setw(8)<<pf[i]<<endl;

}

//DISPLAYING THE AVERAGE SCORE

cout<<"\nThe average score is "<<getAvg(points,count)<<endl;

//DISPLAYING THE AVERAGE STEALS

cout<<"The average steals is "<<getAvg(steals,count)<<endl;

//DISPLAYING THE AVERAGE REBOUND

cout<<"The average rebound is "<<getAvg(rebound,count)<<endl;

//DISPLAYING THE MINIMUM SCORE

minIndex = getMin(points,count);

cout<<"The minimum score by "<<names[minIndex]<<" = "<<points[minIndex]<<endl;

//DISPLAYING THE MAXIMUM SCORE

maxIndex = getMax(points,count);

cout<<"The maximum score by "<<names[maxIndex]<<" = "<<points[maxIndex]<<endl;

return 0;

}

//FUNCTION TO CALCULATE THE AVERAGE SCORE GIVEN THE ARRAY OF SCORES

double getAvg(int points[],int size){

double sum = 0;

for(int i=0;i<size;i++){

sum = sum+points[i];

}

return double(sum/size);

}

//FUNCTION TO RETURN THE INDEX OF PLAYER WITH MINIMUM SCORE

int getMin(int points[], int size){

int minIndex,minScore;

minScore = points[0];

minIndex = 0;

for(int i=1;i<size;i++){

if(points[i] < minScore){

minScore = points[i];

minIndex = i;

}

}

return minIndex;

}

//FUNCTION TO RETURN THE INDEX OF PLAYER WITH MAXIMUM SCORE

int getMax(int points[], int size){

int maxIndex,maxScore;

maxScore = points[0];

maxIndex = 0;

for(int i=1;i<size;i++){

if(points[i] > maxScore){

maxScore = points[i];

maxIndex = i;

}

}

return maxIndex;

}

You might be interested in
The instructions for the OS provided by application software are known as _____.
Galina-37 [17]

Answer:

Pp

Explanation:

I like pp

7 0
2 years ago
True or False? The filtering phase of object-oriented problem solving determines which of the possible classes generated during
tangare [24]

Answer:

The answer is "True".

Explanation:

  • The object-oriented problem-solving, filtering process determines, that only one of the potential classes.It generates through brainstorming was the core class in the solution.
  • In the major issue-solving step, were searching for items important to Sorting. Once we discuss with categories we select. Next, do anything to copies.
5 0
3 years ago
What does this mean?
8090 [49]

Answer:

That you have just wasted your time typing up a seemingly random number sequence.

4 0
2 years ago
Read 2 more answers
What is the main difference between Trademarks and Copyrights?
diamong [38]

Answer:

copyrights protect creative or intellectual works, and trademarks apply to commercial names, phrases, and logos

Explanation:

4 0
2 years ago
Is there such a thing as an ethical reason for unauthorized access to a computer system?
OLga [1]

Meaning of key word here is "unauthorized": We don't have access to use the system. But you are try to accessing an Unauthorized system which is illegal, can be ethical. I think, although not legal in point of where you have to decide of right and wrong. Like if you want to getting information from criminals personal file to catch him then i would be right.

Yes if an administrator want to fix a problem something going on in his/her network wrong,then he/she can access the systems which is attached to network. Like if somebody is trying to access your's network or wifi getting password then you can stop to them use ethically,stop her/him system access to attaching your's network.

6 0
3 years ago
Other questions:
  • Persons who have been given access to an installation can be counted on to be of no threat. true or false? (antiterrorism scenar
    13·1 answer
  • Explain the third <br> generation
    6·1 answer
  • An automated service that consolidates and distributes information from newsgroups, blogs, forums and news websites is called
    11·1 answer
  • What happens when you call someone whose phone is off?
    6·2 answers
  • How do i find the greatest common factor of two numbers?
    14·1 answer
  • What of the following is not a benefit of active listening
    8·2 answers
  • Netflix shows to watch?
    11·2 answers
  • What are the 5 font/typography families
    14·1 answer
  • Alfred works in the human resources department, and he uses a management information system to find applicants' résumés on the w
    7·1 answer
  • scheduling is approximated by predicting the next CPU burst with an exponential average of the measured lengths of previous CPU
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!