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
Households play a role in the circular flow of goods by
BaLLatris [955]

Answer:

People in households buy goods and services from businesses in an attempt to satisfy their unlimited needs and wants.

Explanation:

Households also sell their labor, land, and capital in exchange for income that they use to buy goods and services that firms produce.

6 0
3 years ago
What unit is used for measure disk size ?
Inessa [10]
Inches are the unit of measurements on a disk
8 0
3 years ago
The process of ensuring that web pages coded with new or advanced techniques still are usable in browsers that do not offer supp
Leya [2.2K]

Answer:

(C) progressive enhancement

Explanation:

Progressive enhancement is a web design technique that first underlines the main functionality web page and then incorporates increasingly enhanced and advanced features and design levels.

This process enables the users to use and access the basic features of the web pages. These users can use any browser to access the main contents of the web page. Progressive Enhancement also offers an advanced version of the website for those with more advanced and sophisticated computer browsers or faster internet connection.

So the user can access basic features of a web sites as well as the complex features. This process first makes sure the basic intended purpose and main contents of the web site is accessible to all users before adding complex features which are supported by different browsers and devices.

Validation is a process which checks that code of the website is as per the world wide web standards and also checks that content of web pages and design of websites is being properly displayed and the site is accessible. So this is not the correct option.

Technique of altering a web site in a way that it can appear higher in the search engine results is called optimization so this is not a correct option.

7 0
3 years ago
Web navigation gives the user a sense of control.
Leviafan [203]
1. a.
2. d
3. b
I hope this helps
6 0
3 years ago
Read 2 more answers
Suppose that sales is a two-dimensional array of 10 rows and 7 columns wherein each component is of the type int , and sum and j
Deffense [45]

According to the given question, sales is a two-dimensional array and contains 10 rows and 7 columns wherein each component is of type integer and the variables sum and j are also of integer type.

<u>Explanation:</u>

In order to find the sum of the elements of the fifth row of sales, the correct piece of code should be:

sum=0;

for(j=0;j<7;j++)

sum=sum+sales[4][j];  

The indexing in an array always starts from zero, therefore, to calculate the sum of the fifth row, the user has to write 4 in the index to point to the fifth row.

3 0
3 years ago
Other questions:
  • Using Gen/Spec, classes can be organized by using a peer-to-peer inheritanc True/false
    10·1 answer
  • In a word processing program, the ribbon or menus contain the
    12·1 answer
  • 1. To type a capital "C", you would use the ring finger of your left hand.
    15·2 answers
  • Tom wants a way to automatically create ads and simplify campaign management, using his resources and Google's machine learning
    12·1 answer
  • Constructors have the same name as the ____.1. data members2. member methods3. class4. package
    5·1 answer
  • To rename a database object, press and hold or right-click the object in the navigation pane and then tap or click ____ on the s
    10·1 answer
  • How do you get past a firewall ?
    15·1 answer
  • when I was playing Mobile legends bang bang online Match The game logged Me out and when I was Trying To reconnect it failed and
    5·1 answer
  • Write the definition of a function named fscopy. This function can be safely passed two fstream objects, one opened for reading,
    11·1 answer
  • Fill in the blank with the correct response. Wanting to become a better archer is a what?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!