An array is one name for a list of related items. In this lab, we will work with lists in the form of an array. It will start out simple with a list of numbers. We will learn how to process the contents of an array. We will also explore sorting algorithms, using the selection sort. We will then move onto more complicated arrays, arrays that contain objects.
Create a class called Average according to the UML diagram. see image.
This class will allow a user to enter 5 scores into an array. It will then rearrange the data in descending order and calculate the mean for the data set.
Attributes:
Methods:
1. Copy Average.java and AverageDriver.java into NetBeans or other Java IDE tools. The AverageDriver class only contains the main method to declare and instantiate an Average object, and print the Average object information into the console.
2. Call the selectionSort and the calculateMean methods in the constructor of Average class.
3. Implement the calculateMean method.
4. Compile, debug, and run the program by right click the AverageDriver.java file and select "Run File" on the drop down menu.
1. Copy the files Song.java , CompactDisc.java , and Classics.txt into NetBeans or other Java IDE tools. Song.java is complete and will not be edited. Classics.txt is the data file that will be used by CompactDisc.java. We have learned about data file path in Project for chapter 4.
2. Creating a new song with the title and artist and storing it in the appropriate position in the array.
3. Print the contents of the array to the console.
4. Compile, debug, and run. Your output should be as follows:
Contents of Classics
Ode to Joy by Bach
The Sleeping Beauty by Tchaikovsky
Lullaby by Brahms
Canon by Bach
Symphony No. 5 by Beethoven
The Blue Danube Waltz by Strauss
1. Read "FilePath.doc" to know where to put the Classics.txt.
2. The file input and output part is coded. Try to read through the code and understand the program.
3. Turn in output file "Result.txt" as part of the lab.