Welcome to Legit Writing

LegitWriting LegitWriting

CS 1181
Assignment 9


Liang Chapter 7

Java Application – BattingAverage

Name the Java Class: BattingAverage

Create a Java application that contains uses methods to read in a file that contains batting averages for baseball players, sorts the players by batting average, and displays the top ten players to the user.

The application should have two arrays that will be ran in parallel to store the player’s names and batting averages. It will need to contain at least three methods to do the following:
1) Fill arrays from the given file (Batting.txt)
2) Sort the arrays based on batting order, in descending order. i.e. the player with the highest batting average should be first and the player with the lowest batting average should be last.
3) Display the top ten players with batting averages back to the user.

You will need to extract the number of players in the lists from the first line of the document and use that number to define the length of each array. It will be much easier if you make your arrays global to the class.

Note: sorting one array does not sort the other array. Make sure to arrange both arrays at the same time.

Download the Batting.txt file from Moodle and use it for the input in your assignment.

Program output should look like this:
The following structure chart should help:
Grading Rubric


• Correct File Name (BattingAverage.java) – case sensitive
• Correct Class Name (BattingAverage) – case sensitive
• Correct Style – comments
• Correct Style – method descriptive comments
• Correct Style – indentation
• Correct Style – White Space
• Free of syntax errors
• Using Batting.txt file supplied on Moodle.
o Test for file’s existence.
o Properly use try catch block.
o Close file when done.
• Has two arrays of correct type: one to store player names and one to store batting averages.
• Extracts the number of players from the first line of the file and uses that number to set the size of the arrays.
• Has and uses a method to fill the arrays from the file.
• Has and uses a method to sort the arrays by in descending order by batting average.
o Does not use a built in sort function
• Has and uses a method to display the top ten players by batting average to the user.

Are you interested in this answer? Please click on the order button now to have your task completed by professional writers. Your submission will be unique and customized, so that it is totally plagiarism-free.