Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
java
image text in transcribed
image text in transcribed
image text in transcribed
. . . . 1. Task: Write a Java program using the following methods for a 1-dim array (list): A method named getInt 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 i sallEven 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 1st. You should create a second array holding the squares of the deviations of a value (ist 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/1ne Not an integer! Try again! How many elements in the list 3.5 Hot an integer! Try again How many elements in the list 16 The list is How many elements in the list: 16 The list is: 51 733 67 33 61 4 100 27 80 1 91 10 94 62 95 Your options are: 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print 804 percentile 0) EXIT 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 Box percentile O EXIT Please enter your options a Hot an Integer! Try again! Please enter your option 3.5 Not an integer Try again! Please enter your option 1 Som Viluistare odd. Your options are Your options are: 1) All even values? 2) All unique values? 3) Print min gap between values 4) Statistics 5) Print B08 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 809 percentile 0) EXIT Please enter your options fgfgfd Not an Integer! Try again! Please enter your options 2 Some values/list appear multiple times Your options are: 1) leven values? 2) All unique values? 2) Print thin gap between Values 6) Statistic 5) Print 80 percent 0) EXIT 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 733 67 33 61 4 100 27 80 191 10 94 6295 The mean for this list is: 51.00 The variance for this Istis: 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 01 EXIT Please enter your options The list sorted pile 62 67 80 91 The list sorted: 1 4 7 10 27 33 33 51 61 80-percentile from this list: 100 95 94 94 95 100 Your options are: 1) All even values? 2) All unique values ? 3) Print min gap between values 4) Statistics 5) Print 80% percentile D) EXIT I Please enter your option: 0 Testing completed. LAB #2: ARRAYS, METHODS, FILES 1.Task Write a Java program using the following methods for a l-dim nay (list): . . . . . A method named getInt to get input a valid integer. The method is used to test for type errors in input. A method named initRand to fill the tray 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 army. Use printf. A method named (sallEven that returns a boolean value indicating whether or not all of the values are even numbers A method named fenique 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 Gap that returns the minimum 'gap between adjacent values in the array. The gap between two adjacent values in an amay is defined as the second value minus the first value. A method named menu that prints a list of options and retums a valid option (check the sample output) A method named bubbleSort that sorts the array in ascending onder A method named copy that makes a copy of a l.dim ammay into another I-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 amy and continue with printing the top 20% from this sorted copy. Keep the original array unsorted. A method named yet mean that returns the average value/urray. You may have to overload this method for an array of int/double A method named getvartance that returns the variance of a list of integers. Assume the parameter'method is an array named 11 st. You should create a second array holding the squares of the deviations of a value istit 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: bow tanyelengstallist Hot an togel Tey again How many elements in the list. 3.5 Not an integer! Try asia! How many cats in the 1981 16 The list i 51 33 633 61 4103 27 0 1 10 349 Your tions are 21 A ven val 21 A 3 Printed Sie 51 Pesce - Please enter your option: Your options are: 1) All even Values 2) All unique values? 3) Print min gap between values 6) Statistics S) Print B08 percentile O) EXIT Please enter your options a Not an integer! Try againt Please enter your option 3.5 Not an Integer! Try again! Please enter your option 1 Sone values/list are odd. Your options are: I 21 All even values? 21 All unique values 31 Print min gap between values 4) Statistics 5) Print 804 percentile 0) EXIT Please enter your option: Egged Not an Integer! Try again! Please enter your optionz 2 Some values/list appear multiple times Your options are: 11 A even values 21 All unique values 3) Drint ni gap between abes 41 Statistics 57 Print 80 percentile O EXTE Please enter your option dhe u gap between adjacent valu - Yoar options are: een van 21 ALTO 21 5) Print B04 percentile O] EXIT Please enter your option: 4 S1 7 33 67 33 61 4 100 27 80 91 10 94 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 1 62 95 Your options are: 1) All even values ? 2) All unique values ? 3) Print min gap between values 41 Statistics 3) Print 804 percentile 0} EXIT Please enter your option: 5 The list sorted: 2 4710 27 51 62 62 808-percentile from this list: 100 95 94 I 67 80 91 94 95 100 Your options are: All even values? 21 A unique values? 31 Drint min gap between values 41 Statistics 51 Print 80 percentile 0 EXIT Please enter your options Testing completed

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

Students also viewed these Databases questions

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago