Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the Main class, Change the String value of the PLACE _ NAME variable defined at the beginning of the Main class. The variable must

In the Main class, Change the String value of the PLACE_NAME variable defined at the beginning of the Main class. The variable must remain public static final. The main method reads an input file into a list of Strings called theData and passes the list to a method called convertInput as follows: int[] numbers = convertInput(theData); You must write the body of the convertInput method so that it converts each String in the list to an int and returns the ints in an int[] array. Here is how to do that: Create an int[] object whose length is exactly the same size as the list. Hint: call the size() method on the list to find out how long the array must be. Iterate over the list and convert each String in the list to its int value. Replace the return null; statement at the end of the method with a return statement that returns the array of int values. Most of the code you will write will be in the ArrayAnalyser class. Define an int[] field in the class to store the constructors parameter. Complete the ArrayAnalyser class's constructor so that it stores the integer array parameter in the field you have defined. The array data stored in the field will be analysed by the methods described below that you will add to this class. Write a method in ArrayAnalyser to sum all of the numbers in the numbers array. The method must be called getSum and have a return type of int. It takes no parameters because it will access the values in the array field. The method must return the sum. Write a method in ArrayAnalyser to find the largest of all of the numbers in the numbers array. The method must be called getMax and have a return type of int. It takes no parameters because it will access the values in the array field. The method must return the maximum value. Hint: The java.util.Arrays class contains a static method called sort that can be used to sort an array of ints. Write a method in ArrayAnalyser to count how many of the numbers in the numbers array only occur once in the array. The method must be called getUniqueCount and have a return type of int. It takes no parameters because it will access the values in the array field. For instance, if the array contains the values: 3,5,3,1,7,5 then the method would return the value 2 because there are two values that only occur once: 1 and 7. Write a method in ArrayAnalyser to find the integer value in the numbers array that occurs most frequently. If there are several different numbers that are the most frequent, then the method's result must be the smallest of them. The method must be called getSmallestMostFrequent and have a return type of int. It takes no parameters because it will access the values in the array field. For instance, if the array contains the values: 3,5,3,1,7,5 then the method would return the value 3 because it occurs the same number of times as 5 but 3 is smaller than 5. It turns out that the ArrayAnalyser class is actually part of a secret software application that was meant to be written by Angels helpers, but they got bored with it and went out to play. The numbers in the data file are actually house numbers in Lapland, where there are no street names or postcodes, just house numbers. Santa needs the software to work out the order in which he must deliver gifts. Santa delivers presents by visiting the even-numbered houses first in ascending order of house number and then the odd-numbered houses in descending order. Write a method in ArrayAnalyser called printDeliverOrder. It has a void return type and takes no parameters. This method must print on a two separate lines the house numbers using that ordering for delivery. The numbers must be separated from each other by a single space.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Develop successful mentoring programs. page 400

Answered: 1 week ago