Question: Write a program that will insert random integers into a LinkedList and perform some calculations using methods in the LinkedList class. Create a main class.
Write a program that will insert random integers into a LinkedList and perform some calculations using methods in the LinkedList class.
Create a main class. You will prompt the user to ask them the number of integer objects in your linked list. You will then use a loop to get (for each object) a random number between 1 and 150, create an integer object, and put it in the linked list.
You will then sort the random java integers in your linked list. This will rearrange the integers. You will then use a list iterator to traverse the linked list to print out the index number (make sure you get the index number before you move to the next object), and the random integer number for each of the objects. Use centered column headings for the two columns, and use field widths to line up on the right the two columns of numbers centered under the column headings.
You will then repeat the traversing with the list iterator, but this time sum up the random integers. You will then calculate and print the labeled sum, mean (average to 2 decimal places), range (difference between highest and lowest random integer), and median (middle random integer value) - all without using your input how many variable, but using linked list methods.
Document the class definition code and the program source code with a 4 - 5 line paragraph explaining program at the top and at least 5 lines of explanations throughout program. Run the program with the two runs using the following number of objects. Submit your class definition file, your main program, and an output .txt file saved from the Console.
1st run: 5 objects
2nd run: 25 objects
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
