File IntegerListTest.java contains a Java program that provides menu-driven testing for the IntegerList class. It creates a 10-element array of integers initialized to all 0s and lets you perform various operations on it. Save this file to your directory as well, then compile and run IntegerListTest to see how it works. For example, fill the list with random integers, print it, and use sequential search to look for an element in the list. Does it return the correct index? Now look for an element that is not in the list. It should say "not in list." Now fill the list with new random elements. Note that the driver automatically prints the list when it is filled with new elements.
Modify the code in these files as follows:
Note that you'll have to save the value returned from the first method to pass to the second method.
Add an option to the menu in IntegerListTest to test your new method.
Add an option to the menu in IntegerListTest to test your new method.
Add an option to the menu in IntegerListTest to test your new method. Note that the array must be sorted in increasing order for binary search to work! Don't sort it every time binary search is called -- this is too expensive -- but it's a good idea to remind the user that it should already be sorted in the menu option.
File Square.java contains the shell for a class that represents a square matrix. It contains headers for a constructor that gives the size of the square and methods to read values into the square, print the square, find the sum of a given row, find the sum of a given column, find the sum of the main (or other) diagonal, and determine whether the square is magic. The read method is given for you; you will need to write the others.
File SquareTest.java contains the shell for a program that reads input for squares and tells whether each is a magic square. Following the comments, fill in the remaining code. Run your program on file magicData (you'll need to redirect the input to do this: java SquareTest < magicData) -- you should find that the first, second, and third squares in the input are magic, and that the rest (fourth through seventh) are not. Note that the -1 at the bottom tells the test program to stop reading.