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]
4 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]4 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
Which ribbon tab is home to the Function library used to insert functions into worksheets?
Sedaia [141]
The correct answer is C: Formulas
3 0
3 years ago
Read 2 more answers
If your cousin wanted to view information from the world wide web, what application software would you tell her to be sure she h
MAVERICK [17]
Well, I would say a web browser, like Mozilla Firefox, Safari for IOS, Windows Edge, Chrome, or Internet Explorer; and some anti-malware software, since there are multiple websites on the WWW that try to steal your information and give your device viruses.
6 0
3 years ago
Pinterest, a visual bookmarking Website, logs more than 14 terabytes of new data each day, which means its storage needs are con
Wewaii [24]

Answer:

The correct answer is option (A).

Explanation:

Pinterest has turned to amazon for storage as a service because it continuously needs a large amount of storage as given in the scenario.

While the other options are not correct because of the following reasons:

  • Grid computing can be defined as the concept of connection between a large number of computers in an architectural way who work to obtain the same goal but grid computing can not fulfill the need for storage for Pinterest.
  • Cloud computing can work as data storage which can be accessed from the internet anywhere but this can not fulfill the storage requirements for Pinterest as they are very huge.
  • Infrastructure as a service is not correct because the need of the company is for storage.

4 0
4 years ago
Explain the five generations of computer
liubo4ka [24]

Answer:

1 First Generation

The period of first generation: 1946-1959. Vacuum tube based.

2 Second Generation

The period of second generation: 1959-1965. Transistor based.

3 Third Generation

The period of third generation: 1965-1971. Integrated Circuit based.

4 Fourth Generation

The period of fourth generation: 1971-1980. VLSI microprocessor based.

5 Fifth Generation

The period of fifth generation: 1980-onwards. ULSI microprocessor based.

5 0
3 years ago
Read 2 more answers
Helloooooo people, thats all I just wanted to say :D​
Salsk061 [2.6K]

Answer:

Hi also thank you for the points very much appreciated.

6 0
3 years ago
Other questions:
  • An agile team used planning poker to estimate user stories. After all team members read a user story, the facilitator asks every
    7·1 answer
  • An operating system is an example of _______. The hard drive, keyboard and monitor are example of_______.​
    11·1 answer
  • What college degrees did Steve Wozniak earn?
    10·1 answer
  • Java - Using a method, how do I "write a program whose input is a character and a string, and whose output indicates the number
    8·1 answer
  • What is the default file extension for a document created in Word 2016​
    13·1 answer
  • Angelina has added page numbers to her report, but all of the pages are labeled "Page 1" at the bottom. What caused
    8·2 answers
  • Colin Mackay Inc., a software company with its head office in Amsterdam, has employees across three continents. Certain project
    11·1 answer
  • Mai lee wants to add a graphic demonstrating a process in her document. which of the following commands should she click in the
    5·1 answer
  • How can you create a messages to look like an IMessage?
    8·1 answer
  • 04. Suppose a computer program needs to sort a list of student records in ascending order
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!