Description
Snowball Fight
A text file named snowball.txt contains a 3-digit Team ID, number of times the team hit a member of another time (hits), and the number of times a member of this team was hit (times hit) for each team participating in a campus-wide snowball fight. The data is organized on up to 50 lines in the data file, as shown below.
182 37 12
837 14 25
374 29 28
…
Write a program that allows the user to enter a team’s ID and displays the number of hits for that team. You must use the binary search algorithm studied in Unit 1 in this program. Your program should do the following:
- Read the data from the file into partially filled, parallel arrays.
- Sort the arrays, in parallel, putting the IDs in increasing order and keeping the number of hits and times hit in parallel with them. (When you swap two elements in the ID array, also swap the corresponding elements in the hits and times hit arrays.)
- Enter a loop that does the following until the user chooses to quit:
- Read a team ID from the user
- Use the Binary Search algorithm to find the number of hits and times hit for that team.
- Print the number of hits, and times hit for the team requested. If the hits is greater than the times hit, print a Congratulations message.
If the ID entered is not in the data, print a “Not Found” message.
Your program must be modular, with separate functions to: read the data file, sort the arrays in parallel, input a number from the user, search, and print the results. Your output should be well-organized, neat, and easy to read.
Design your program by completing the CSC 250 Program Design Document. Be sure to include a structure chart for the program, a prototype for each function, and time estimates for program design, coding each function, program testing, and total time. Save the design in a file named SnowballDesign_xxx.doc where xxx are your initials. Submit your program design in the Program 1 Design drop box by the due date shown in the calendar and drop box tools. (This is before the Program due date).
Write your program.
Save your program in a file named snowball_xxx.cpp where xxx are your initials.
Compile, run and test your program.
Update the structure chart & function descriptions in your Program Design Document to fit your working program. Update the time estimates based on actual time spent.
Submit your updated Program Design document and working .cpp file in the Program 1 drop box by the due date shown in the calendar and drop box tools.