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
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 ...
This solution provides an example Java program that uses an array to store data and sorts the array.
Java List Arrays Example: Class SList
Use the following shell class SList, and complete its implementation as per the guidance in points 1 through 5. Read the documentation on the member function declarations carefully.
public class SList
public void insert(int item);
// Pre: The list is not full
// item is not in the list
// Post: item is in the list; the items are in sorted order
public void printList()
// Post: If the list is not empty, the elements are
// printed on the screen; otherwise "The list
// is empty" is printed on the screen
public int getLength()
// Post: return value is the number of items in the list
public boolean isEmpty()
// Post: returns true if list is empty; false otherwise
public boolean isFull()
// Post: returns true if there is no more room in the
// list; false otherwise
// Post: Empty list is created with maxItems cells
// Data fields
private int numItems;
private int values;
1: Write the definitions for the member functions.
2: Write a driver program that reads values from file int.dat, stores them in the list, and prints them on the screen.
3: Add a boolean method "contains" to class SList that returns true if its parameter is in the list and false otherwise. Use the binary search algorithm.
4: Add a private variable currentItem to the list and implement these method headings. This combination allows the user to view the list items, one at a time.
public void resetList()
// Set currentItem to 0
public String next()
// Returns the item at values[currentItem]
// Increments currentItem
public boolean hasNext()
// Returns true if currentItem is not equal to numItems
5: Augment the driver in point 2 to demonstrate how to use resetList, hasNext, and next to print the list.View Full Posting Details