Question
Define a class named IntegerList that contains: - An instance data named list, an array of integers. - A constructor that accepts an array size
Define a class named IntegerList that contains: - An instance data named list, an array of integers.
- A constructor that accepts an array size and creates a list of that size.
- A getter and setter method for every instance data.
- A randomize()method that fills the list with random integers between 1 and 100, inclusive.
- A toString method that returns a string containing the list elements, separated by spaces.
- A method merge() that merges two integer lists into one integer list and returns it, where elements of the first list are followed by those of the second list.
(ii) The IntegerList class in part (i) can be used to store random exams scores of a class of students. Assuming all classes enroll the same number of students, need an application IntegerListTest that asks the user for a class size and number of classes. The driver program creates and fills (randomly) all those lists. The program then merges them and prints to the screen the resulting list (elements separated by spaces).
For example, if the class size is 5 and number of classes is 3, the following could be the random scores and the merged list output:
54 85 98 78 100
88 78 45 99 38
22 19 87 65 87
54 85 98 78 100 88 78 45 99 38 22 19 87 65 87
(iii) Writeup the equals() method for the class IntegerList in part (i). The method compares two IntegerList objects and returns true if the two lists are identical, i.e. they have same elements in same order, and false otherwise.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import javautilArrays import javautilRandom public class IntegerList private int list public Integer...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