Question
need help at java coding. You will be reading a file that has the bowling score of multiple players. The name is followed by how
need help at java coding.
You will be reading a file that has the bowling score of multiple players. The name is followed by how many games were bowled which is followed by the actual scores. For example, Sam bowled 3 games with scores of 120, 200 and 110.You dont not know in advance how many total players there will be in the file but you can assume there will not be more than 50
Sample contents
Sam 3 120 200 110
Julie 4 200 210 190 175
Fred 2 98 100
1)Write a method readData which will read all the records and store the data as follows:
Read in the bowlers name and assign the name to the String array names.
Read in the number of scores (3 for Sam) and then read the actual scores for that bowler (110, 98 and 135) keeping a running total of the scores.
Using the running total, compute the average score and store it in the array of double named avgScore.
So names[0] will have Sam, avgScore[0] will have 114.33
The method readData passes back to main the actual number of bowlers read in which will be used in subsequent method calls.
The signature of header for the method is
int readData(String[] names, double[] avgScore) throws IOException
2)Write two methods called paralleSort
The first will sort on the String array (names) in ascending order and keep the double array (avgScore) in synch. It has the header
void parallelSort (String[] arrStr, double[] arrDbl, int ndx)
where ndx is the actual number of records read in from the input file
The second will sort on the double array (avgScore) in descending order and keep the String array (names) in synch. It has the header
void parallelSort (double[] arrDbl, String[] arrStr, int ndx)
where ndx is the actual number of records read in from the input fil
3)Write the code for a method binarySearch which will search for a specific name in the names array. If found, it will print the name and the average score; if not found it will print that the name is not found.
The header is
public static int binarySearch(String[] list, String key, int ndx)
Note that an additional parameter of int ndx is needed because there may not be 50 names in the array and we dont want to search through empty values. This will replace the actual array length in the algorithm to calculate the initial vale of high
Test the algorithm by searching for the name Sam and searching for the name Roberta.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started