CS 1050 Array of Structures Codes Lab Report

User Generated

IvpxlObo

Programming

CS 1050

CS

Description

Description

To get started on this lab, type the following while logged in to tc.rnet.missouri.edu: DON’T FORGET THIS

cs1050start lab13

For the lab assignment, you are to start with the starter code provided in the lab13 directory.This is basically a solution to the prelab, so it should look somewhat familiar.Note that this is just code to get you started.You may prefer to use your own prelab code instead, especially if you defined some cool new structs in your code.

Your job in this lab is to calculate 3 new statistics for the baseball players from your prelab.These statistics are:

  • Batting Average (AVG) – This is total hits divided by at-bats.To calculate total hits, just add singles plus doubles plus triples plus home runs.
  • On-base Percentage (OBP) – This is (total hits plus walks) divided by (at-bats plus walks).Use the definition of total hits as above.
  • Slugging Percentage (SLUG) – This is total bases divided by at-bats.Total bases = singles + 2*doubles + 3*triples + 4*homeruns.

Once you have these statistics calculated for all of the players, you will print out the players along with these stats in 4 different sorting orders:

  • The initial orders the players are read in by GetNextPlayer() (this is really in ascending order by ID).
  • By batting average descending (this means print the player with the highest batting average first, the second highest batting average second, etc.)
  • By on-base percentage descending (highest obp down to lowest obp)
  • By slugging percentage descending (highest slug down to lowest slug)

Unformatted Attachment Preview

CS1050 – Lab 13 Fall 2020 Concepts to Practice • • • Structures Arrays of structures Sorting Submission Information Submit this assignment by following the instructions given by your TA. SUBMIT ONLY the .c file (no a.out or executable file is required). All of the lab assignments must be submitted before the end of the lab using the lab code given by the TA. Use the following submit command: mucs submit For example: mucs submit 1050 lab lab13.c Description To get started on this lab, type the following while logged in to tc.rnet.missouri.edu: DON’T FORGET THIS cs1050start lab13 For the lab assignment, you are to start with the starter code provided in the lab13 directory. This is basically a solution to the prelab, so it should look somewhat familiar. Note that this is just code to get you started. You may prefer to use your own prelab code instead, especially if you defined some cool new structs in your code. Your job in this lab is to calculate 3 new statistics for the baseball players from your prelab. These statistics are: 1. Batting Average (AVG) – This is total hits divided by at-bats. To calculate total hits, just add singles plus doubles plus triples plus home runs. 2. On-base Percentage (OBP) – This is (total hits plus walks) divided by (at-bats plus walks). Use the definition of total hits as above. 3. Slugging Percentage (SLUG) – This is total bases divided by at-bats. Total bases = singles + 2*doubles + 3*triples + 4*homeruns. Once you have these statistics calculated for all of the players, you will print out the players along with these stats in 4 different sorting orders: • • • • The initial orders the players are read in by GetNextPlayer() (this is really in ascending order by ID). By batting average descending (this means print the player with the highest batting average first, the second highest batting average second, etc.) By on-base percentage descending (highest obp down to lowest obp) By slugging percentage descending (highest slug down to lowest slug) Hints • It is a lot easier to sort things if you have all of your data if it is all in an array of structures. BONUS For bonus points, determine the number of players and then dynamically allocate space to store the players (so you will have the exact right amount of space). Hint: There are 2 functions in basicplayer.h – you will probably need to use both of them. Sample Output jimr@JimRArea51:~/CS1050/FS2020/labs/lab13$ make compile -c lab13.c compile -c basicplayer.c ar rs libbasicplayer.a basicplayer.o ar: creating libbasicplayer.a compile lab13.o -lbasicplayer -L. -o stats jimr@JimRArea51:~/CS1050/FS2020/labs/lab13$ ./stats *** Initial order *** AVG OBP SLUG NAME 0.265 0.358 0.444 Darrell Porter 0.291 0.416 0.547 John Mayberry 0.275 0.314 0.399 Frank White 0.220 0.281 0.282 Fred Patek 0.269 0.317 0.427 George Brett 0.332 0.360 0.431 Willie Wilson 0.298 0.382 0.525 Amos Otis 0.274 0.318 0.388 Al Cowens 0.273 0.328 0.429 Hal McRae 0.287 0.379 0.512 Ted Simmons 0.299 0.402 0.413 Keith Hernandez 0.234 0.304 0.282 Tom Herr 0.303 0.393 0.383 Ozzie Smith 0.230 0.260 0.334 Ken Reitz 0.288 0.337 0.497 George Hendrick 0.353 0.387 0.503 Willie McGee 0.267 0.321 0.335 Vince Coleman 0.321 0.373 0.453 Lonnie Smith 0.216 0.266 0.338 Tom Poquette 0.265 0.324 0.326 Dane Iorg 0.207 0.270 0.293 Tom Lawless 0.264 0.317 0.295 U.L. Washington *** By Average *** AVG OBP SLUG NAME 0.353 0.387 0.503 Willie McGee 0.332 0.360 0.431 Willie Wilson 0.321 0.373 0.453 Lonnie Smith 0.303 0.393 0.383 Ozzie Smith 0.299 0.402 0.413 Keith Hernandez 0.298 0.382 0.525 Amos Otis 0.291 0.416 0.547 John Mayberry 0.288 0.337 0.497 George Hendrick 0.287 0.379 0.512 Ted Simmons 0.275 0.314 0.399 Frank White 0.274 0.318 0.388 Al Cowens 0.273 0.328 0.429 Hal McRae 0.269 0.317 0.427 George Brett 0.267 0.321 0.335 Vince Coleman 0.265 0.358 0.444 Darrell Porter 0.265 0.324 0.326 Dane Iorg 0.264 0.317 0.295 U.L. Washington 0.234 0.304 0.282 Tom Herr 0.230 0.260 0.334 Ken Reitz 0.220 0.281 0.282 Fred Patek 0.216 0.266 0.338 Tom Poquette 0.207 0.270 0.293 Tom Lawless *** By OnBase Pct AVG OBP SLUG 0.291 0.416 0.547 0.299 0.402 0.413 0.303 0.393 0.383 0.353 0.387 0.503 0.298 0.382 0.525 0.287 0.379 0.512 0.321 0.373 0.453 0.332 0.360 0.431 0.265 0.358 0.444 0.288 0.337 0.497 0.273 0.328 0.429 0.265 0.324 0.326 0.267 0.321 0.335 0.274 0.318 0.388 0.269 0.317 0.427 0.264 0.317 0.295 0.275 0.314 0.399 0.234 0.304 0.282 0.220 0.281 0.282 0.207 0.270 0.293 0.216 0.266 0.338 0.230 0.260 0.334 *** NAME John Mayberry Keith Hernandez Ozzie Smith Willie McGee Amos Otis Ted Simmons Lonnie Smith Willie Wilson Darrell Porter George Hendrick Hal McRae Dane Iorg Vince Coleman Al Cowens George Brett U.L. Washington Frank White Tom Herr Fred Patek Tom Lawless Tom Poquette Ken Reitz *** By Slugging Pct *** AVG OBP SLUG NAME 0.291 0.416 0.547 John Mayberry 0.298 0.382 0.525 Amos Otis 0.287 0.379 0.512 Ted Simmons 0.353 0.387 0.503 Willie McGee 0.288 0.337 0.497 George Hendrick 0.321 0.373 0.453 Lonnie Smith 0.265 0.358 0.444 Darrell Porter 0.332 0.360 0.431 Willie Wilson 0.273 0.328 0.429 Hal McRae 0.269 0.317 0.427 George Brett 0.299 0.402 0.413 Keith Hernandez 0.275 0.314 0.399 Frank White 0.274 0.318 0.388 Al Cowens 0.303 0.393 0.383 Ozzie Smith 0.216 0.266 0.338 Tom Poquette 0.267 0.321 0.335 Vince Coleman 0.230 0.260 0.334 Ken Reitz 0.265 0.324 0.326 Dane Iorg 0.264 0.317 0.295 U.L. Washington 0.207 0.270 0.293 Tom Lawless 0.220 0.281 0.282 Fred Patek 0.234 0.304 0.282 Tom Herr Guidelines for Grading Lab 13 40 Points Possible (+5 bonus points) General If your program does not compile or produce any input/output (I/O) because most of the source code is commented out then your lab will receive a grade of ZERO POINTS. Further, if your program does not actually follow the specifications, but merely prints out lines that make it appear to follow the specifications, you will receive a grade of ZERO POINTS. For partial credit your C program must not only compile but also produce some valid I/O that meets the lab specifications. You program is expected to have a comment header at the top that includes your name, pawprint, the course you are taking, and the lab that you are solved (e.g., “Lab 13”). Your code should be nicely indented. You may not use global variables. You will lose up to 10 points if you do not meet these basic requirements. 5 points: Your code correctly calculates AVG for each player. 5 points: Your code correctly calculates OBP for each player. 5 points: Your code correctly calculates SLUG for each player. 5 points: Your code prints the players in the correct initial order. 5 points: Your code prints the players in AVG descending order. 5 points: Your code prints the players in OBP descending order. 5 points: Your code prints the players in SLUG descending order. 5 points: Your output closely matches the example output. BONUS (5 points) 5 points: You dynamically allocate an array of structures, based on the exact number of players. You cannot simply count the number of players manually. Your program must work if I change the number of players (it must calculate the number of players via code; not via human counting). NOTICE FOR BONUS THE CODE HAS TO DETERMINE THE NUMBER OF PLAYERS, NO HARD CODING
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

I almost sure that this is true.But I couldn't test it because profe...


Anonymous
Awesome! Perfect study aid.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Similar Content

Related Tags