Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Task: Write a Java program using the following methods for a 1-dim array (list): A method named get Int to get input a

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1. Task: Write a Java program using the following methods for a 1-dim array (list): A method named get Int to get input a valid integer. The method is used to test for type errors in input. A method named initRand to fill the array with random values: the elements of the array should be random integers between 1 and 100 (declared as class constants). A method named print to print the elements of the array. Use printf. A method named isAllEven that returns a boolean value indicating whether or not all of the values are even numbers. A method named isUnique that returns a boolean value indicating whether or not the values in the array are unique. The values in the list are considered unique if there is no pair of values that are equal. A method named minGap that returns the minimum 'gap' between adjacent values in the array. The gap between two adjacent values in an array is defined as the second value minus the first value. A method named menu that prints a list of options and returns a valid option (check the sample output). A method named bubbleSort that sorts the array in ascending order. A method named copy that makes a copy of a 1-dim array into another 1-dim array. A method named top_20 that prints the values in the 80%-percentile (top 20%). The method should start with sorting a copy of the array and continue with printing the top 20% from this sorted copy. Keep the original array unsorted. A method named getMean that returns the average value/array. You may have to overload this method for an array of int/double A method named getVariance that returns the variance of a list of integers. Assume the parameter/method is an array named list. You should create a second array holding the squares of the deviations of a value (list[i]) from its mean value. The variance is the mean of this second array. NOTE: The sample output shows also the standard deviation for option 4. The standard deviation is the square root of the variance. No need for a method. All methods should take as input parameters the array and its size. Write a driver program to call these methods and get output similar to the sample output below. SAMPLE OUTPUT: How many elements/list: a Not an integer! Try again! How many elements in the list: 3.5 Not an integer! Try again! How many elements in the list: 16 The list is: 51 7 33 67 33 61 4 100 27 80 1 91 Your options are: 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print 80% percentile 0) EXIT 10 94 62 95 Please enter your option: 8 Your options are: ---- 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print 80% percentile 0) EXIT Please enter your option: a Not an integer! Try again! Please enter your option: 3.5 Not an integer! Try again! Please enter your option: 1 Some values/list are odd. Your options are: 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print 80% percentile 0) EXIT Please enter your option: fgfgfd Not an integer! Try again! Please enter your option: 2 Some values/list appear multiple times Your options are: 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print 80% percentile 0) EXIT Please enter your option: 3 The minimum gap between 2 adjacent values is -81 Your options are: 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print 80% percentile 0) EXIT Please enter your option: 4 51 7 33 67 33 61 4 100 27 80 1 91 The mean for this list is: 51.00 The variance for this list is: 1165.88 The standard deviation for this list is: 34.14 Your options are: 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print 80% percentile 0) EXIT Please enter your option: 5 The list sorted: 1 4 7 10 27 33 33 51 61 80%-percentile from this list: 100 95 Your options are: 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print 80% percentile 0) EXIT Please enter your option: 0 Testing completed. 62 67 10 80 91 94 62 95 94 95 100

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

Step: 3

blur-text-image

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

Microsoft Visual C# An Introduction to Object-Oriented Programming

Authors: Joyce Farrell

7th edition

978-1337102100

More Books

Students also viewed these Programming questions

Question

Define the term utility software and give two examples.

Answered: 1 week ago