Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write a C++ program following and using the given image Snowball Fight A text file named snowball.txt contains a 3-digit Team ID, number of

please write a C++ program following and using the given image
image text in transcribed
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. 182837374371429122528 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: 1. Read the data from the file into partially filled, parallel arrays. 2. 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.) 3. Enter a loop that does the following until the user chooses to quit: a. Read a team ID from the user b. Use the Binary Search algorithm to find the number of hits and times hit for that team. c. 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 wellorganized, neat, and easy to read

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions