Share
Explore BrainMass

Example Java program using arrays and sort algorithms

Write a program that allows the user to enter students' names followed by their test scores and output the following information(assume that the maximum number of students in the class is 50):

a. Class average

b. Names of all the students whose test scores are below the class average, with an appropriate message

c. Highest score and the names of all students have the highest score

example of the data.txt file format:

AAA 85
BBB 90
CCC 100
DDD 85
... ...
... ...

Solution Preview

This solution shows how to use an array in Java and how to read data from a file. We use two Java classes. The first class, ScoreData, is just for storing the name and score values for a particular data item. The class constructor takes the name and score for a particular
item. There are accessor methods to get the name and score out.

Most of the work is done in the Scores class. This class contains an array of ScoreData items. The array is loaded with the ...

Solution Summary

This solution provides an example Java program that uses an array to store data and sorts the array.

$2.19