CS 1336 – PROJECT 5 – Mario Super Sluggers 2
Pseudocode Due: Section 504 (M/W) – 11/21 by 11:59 PM
Section 005 (T/R) – 11/20 by 11:59 PM
Project Due: Section 504 (M/W) – 12/10 by 11:59 PM
Section 005 (T/R) – 12/10 by 11:59 PM
This project uses the basic logic from project 4 and implements it in a different way. Changes are in blue.
Submission and Grading: All programs are to be submitted in eLearning. The pseudocode should be submitted as a Word or PDF document. Please submit the program as a .cpp file only. Projects submitted after the due date are subject to the late penalties described in the syllabus. Programs must compile and run in Code::Blocks. Each submitted program will be graded with the rubric provided in eLearning as well as a set of test cases. These test cases will be posted in eLearning after the due date. Each student is responsible for developing sample test cases
to ensure the program works as expected.
Objective: Implement array constructs into a modular program. Utilize basic techniques of program maintenance.
Problem: Now that the Mushroom Kingdom League has ended and crowned a new champion, it is time to determine the league leaders in several different baseball categories. Being the only person in the MushroomKingdom that knows how to write a computer program, you have been asked by Princess Peach herself to write a program that will determine the league leaders.
Details:
Stats will be calculated for the following categories:
o Batting Average (BA)
Batting average = hits / at-bats
o On-base percentage (OB%)
On-base percentage = (hits + walks + hit by pitch) / plate appearances
o Strikeouts (K)
o Walks (BB)
o Hit by Pitch (HBP)
o Hits (H)
All input will be read from a file
All output will be written to a file
Calculate all stats per person and record the highest value for each category
o There may be ties now for the leaders
o If there is a tie, output all names for tied value
Arrays must be implemented in the program
o Consider using an array for each category in parallel
o The size of each array will be 30
Search through the arrays to find the league leaders
o Do not use individual variables to hold the league leaders
The program must use a minimum of 3 functions other than main
o Remember each major, logical piece of the program should be a separate function
The main function must call at least 3 of the functions you create
Any global variables used must be constant
Use as few variables as possible
User Interface: There will be no user interface for this program since all input will be read from a file.
Input: All input will be read from a file. Each player’s data will be listed on separate lines in the file and will follow the same format.
The input file will be named stats.txt
Format: <name><space><batting record>
o Mario HOOKWSHHKOHPWWHO
The name will be a single word.
The batting record will be a series of capital letters representing various results during a baseball game
o H – hit
o O – out
o K – strikeout
o W – walk
o P – hit by pitch
o S – sacrifice
Walks, sacrifices and hit by pitches are not considered an at-bat
Batting records may contain invalid characters.
o If an invalid character is encountered, disregard it
o Invalid characters are not counted as an at-bat
Each line in the file will end in a newline (including the last line of the file)
Consider using nested loops – the outer controlling reading each line and the inner controlling reading the batting record
The batting record should be read a character at a time.
o Process each character before reading the next
The batting record for each person may not have the same number of results
o The newline character at the end of the line is the key
Review the sample file posted in eLearning
Output: All output will be written to a file named leaders.txt. Output should only occur at the end of the program.
Each person’s individual stats should be written to the file. After each person’s stats have been written to the file, write the league leaders for each category to the file. Review the sample file posted in eLearning.