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
Each object that is created from a class is called a(n) ____________ of the class.
gladu [14]
Instance





-------------------------
7 0
3 years ago
Read 2 more answers
How are special characters added to a Word document? Check all that apply.
Musya8 [376]

Answer:

by using keystroke codes

by using the character map

by using the Symbols command group

by using the Symbol drop-down arrow

6 0
3 years ago
Read 2 more answers
Explain how inflation flattens the universe
DIA [1.3K]
They rise to the surface of the earth
8 0
3 years ago
Read 2 more answers
What will be returned when the following SQL statement is executed?
ycow [4]

Answer:

b) A listing of each driver as well as the number of deliveries that he or she has made

Explanation:

SQL which stands for Structured Query Language. and an SQL statements are used in performing tasks such as to update data on a database, or retrieve data from a database. Some of the popular relational database management systems that use SQL are: Sybase, Oracle, Microsoft SQL Server, Ingres, Access, etc.

3 0
3 years ago
Read 2 more answers
Scale-based classification for networks allows us to differentiate PANs, LANs, MANs, and WANs. Moreover, the structure of a netw
Nana76 [90]

Answer:

1. PANs uses Star Topology.

2. LAN uses four topology (Bus, Ring, Star and Tree).

3. MAN uses Star Topology.

4. WAN uses Bus topology.

Explanation:

1. PAN is the personnel area network, in which different personnel devices of a person are connect to each other with the help of the central computer with the help of Bluetooth, WiFi or some other medium. The central computer will work like a hub and all the devices are directly connected to the central PC. It is same as the ring topology where all the devices are connected to the central PC. So we can say that, PANs use star topology.

2. LAN is the local area network that has been established with in the premises of the organization. In this type of network, four typologies involve to complete the network connection. First is star topology, that is used to connect all the devices with the switches. Then Bus topology is used to connect all the switches with the single main cable. Ring topology is involved to connect all the switches with each other. Tree topology is used to connect different block if the organization in the form of branch to connect the central router or switch.

3. MAN is the Metropolitan Area Network which is comprise of different LANs. All the LANs are connected to the Router in the form of Star topology.

4. WAN is the wide area network. In WAN different MANs are connected to the network through single cable. This type of network uses Bus topology.

6 0
3 years ago
Other questions:
  • What is the name of the feature that can be enabled on slower-speed WAN links to prevent a large data transfer from affecting th
    10·1 answer
  • It can be useful to have a mentor because they will help you
    7·2 answers
  • How might writing an online journal be different than writing in a paper one ​
    15·2 answers
  • Dora electronically transferred $591.68 from her checking account to Matt's checking account. In what column of the check regist
    14·2 answers
  • What would be one duty of a network administrator
    12·1 answer
  • What natural resource are available on the coast but not somewhereelse
    13·1 answer
  • I love dog my is 16 weeks old how old is yours
    12·1 answer
  • In how many positions are there nucleotide differences between your query sequence and the sequence of accession AY259214.1
    12·1 answer
  • What are 3 of the most important things about internet safety that you would recommend and why
    15·1 answer
  • while determining which antibiotics are best to treat ulcers caused by helicobacter pylori, the drugs used in the experiment are
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!