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

Write a complete C++ program to process league statisticsfor the Western Collegi

ID: 3613832 • Letter: W

Question

Write a complete C++ program to process league statisticsfor the Western Collegiate Hockey Association.

• maximum of 12 teams per season.

o use an array of structure variables to store the collection ofindividual team statistics.

• read the team statistics from a text file whose filename is entered at the command line.

o if no file name is specified then prompt the user for the filename.

• Each line in the file contains statistics for one team(no blank lines).

o NAME WINS LOSSES TIES

Data File Example:

Bulldogs 2 11 5                 // 0 or more blanks in front of the name field

Gophers 7 3 1          // 1 or moreblanks in front of the other fields

Solution Algorithm:

1. Display a message on the screen that describes to the userwhat the program does

a. Part of the required program documentation (introductionfunction).

2. Read one team from the data file read one entire line as a single string value.

a. Build the individual statistic values for the current teamone character at a time:

i. name, wins, losses, and ties seenote 2 below.

b. Store each statistic value in the appropriate structurevariable field within the team array using appropriate data types the only string value stored is thename.

3. Calculate the individual team statistics:

a. Points: 2 points for a win and 1 point for a tie see note 3 below.

b. Points/Game: ratio of points to games played see note 3 below.

4. Sort the teams in alphabetical order A..Z, a..z.

5. Calculate the league statistics:

a. Sums: wins, losses, ties

b. Points: 2 points for a win and 1 point for a tie see note 3 below.

c. Points/Game: ratio of points to games played see note 3 below.

6. Display the individual team statistics and league statisticsusing the format shown below.

Notes:

1. Each step (1..6) is a task. Each task requires at least onefunction. Do not reorder the tasks.

2. Build all string values using the exact same technique.

o Define and reuse a function that can build exactly one stringvalue.

3. Individual team statistics and league statistics arecalculated using the same technique.

o Define and reuse a function that can be used for theindividual teams and for the league.

WCHA

Name   Wins   LossesTies     Points Points/Game

Badgers 0       0         0        0         0.0

Beavers 11      2        2         24       1.6

Bulldogs 2      11       5         9         0.5

Gophers 7       3        1          15      1.4

Mavericks 8    12      6         22       0.8

Seawolves 15 15        4         34       1.0

Totals        43 43       18       104     1.0

Required user-define data types:

Team structure data type used to describe oneteam (one hockey team – one hockey league)

Line C style character string data type

Maximum of 80 characters don't forgetthe NULL character

Basic Program Layout:

void getFilename( const int, const char* [], Line & )// global function declarations

// other required functions

int main( const int argc, const char* argv[] ) //general solution algorithm

getFilename( argc, argv, filename );

while ( !inFile.getline( oneLine, LINE_SIZE, ‘ ’).eof( ) ) // ‘ ’ terminates – not stored

// process current line oneLine is type Line – LINE_SIZEis 80

// build each team statistic one at a time as a string value

// name, wins, losses, ties

// store each statistic using an appropriate data type

// process individual team statistics

// sort the teams

// process league statistics

// generate output

Use conventions discussed in class:

1. Identifier naming: variables, constants, functions,user-defined data types

2. Use of constants and arrays: LINE_SIZE, LEAGUE_SIZE

3. Use of user-defined data types

4. Do NOT use global variables under any circumstances

a. Constants, user-defined data types, and functions whereappropriate ONLY

5. Etc…

Additional resources needed:

1.      cstring Cstyle string tools

2.      cstdlib atoi– converts C style string values to integers

sortTeams( teams, size ) // Bubble Sort pseudocode

for pass 1..size-1

for comp 1..size-pass

if teamA.name > teamB.name

swapTeams

Explanation / Answer

please rate - thanks took forever - you should be able to make any changes #include #include #include #include using namespace std; #define Max_teams 10 struct record {string name; int wins; int losses; int ties; int points; double ppg; }team[Max_teams],temps; void message(); int getinfo(record [],ifstream& ); void decode(record[],string,int); string unpackit(string,int&); void process(record[],int); void sort(record[],int); void print(record[],int); int main(int argc, char * argv[]) { char filename[20]; string s; ifstream in; int i=0; message(); if (argc==1)         {couts;         }      else         s=argv[1]; for(i = 0;i
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