1. Task: Write a Java program using the following methods for a 1-dim array (list): A...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell
Posted Date:
Students also viewed these programming questions
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Campione Manufacturing acquired an 80% interest in DaLuca Distributors, a foreign corporation established on November 1, 2006, for 650,000 foreign currency units (FC). Campione acquired its 80%...
-
This chapter divides not-for-profit entities into four categories that align with accounting and auditing standards. What are the four categories and what types of entities are included in each?
-
Otis is a mechanical engineer who designs a 1900 kg elevator to accelerate downward at a rate of 1.10 m/s. Determine the magnitude of the tension in the cable during a test run of this system. [16.5...
-
How to organize litigation files for trial?
-
Jennifer Ross, an employee of Hampton Company, worked 44 hours during the week of February 9 through 15. Her rate of pay is $ 30 per hour, and she receives time- and- a- half for work in excess of 40...
-
13. Calculate the engineering strain (inch/inch) for a beam of stainless steel under tensile stress with an original length of 22" and a gage length of 24.75". (5 points)
-
Consider the following Mini-Triangle program let in yarn: Integer; proc p () - nn 2 begin n = 9; p() end (a) Draw the decorated AST for this program (b) Produce the identification table for this...
-
1. A LAN has a data rate of 4 Mbps and a propagation delaybetween two stations at opposite ends of 20 s. For what range ofPDU sizes does stop-and-wait give an efficiency of at least50%? 2. A...
-
Two dice were rolled forty times and then the sum of the two dice were calculated after each roll. Complete the following calculations. Sums: 9, 8, 9, 8, 7, 4, 3, 7, 11, 9, 7, 6, 7, 10, 12, 6, 6, 4,...
-
The partnership of Ramos, Rios, Safar, and Wong is being liquidated. It currently holds cash of $22,600 but no other assets. Liabilities amount to $51,400. The capital balances are Ramos (40% of...
-
Y 3. Expand Y x ( % 1 ) ( 2 + 3 )
-
Jim paid $12.53 for a 7.03-kg bag of dog food. A few weeks later, he paid $14.64 for a 7.98-kg bag at a different store. Find the unit price for each bag. Then state which bag is the better buy based...
-
In your opinion, should sex offenders' personal information, such as their home address, work address, physical description, list of vehicles, details relating to the offense(s), etc. be shared with...
-
Question 25 True|False: RAM is main memory, which is volatile because its data will be lost when power is off. True False Question 26 True|False: Secondary storage holds its data and programs even...
-
Define the term utility software and give two examples.
-
Which of the following opens the payroll.txt file for output? The file is associated with the outPayroll object. a. outPayroll.open("payroll.txt"); b. outPayroll.open("payroll.txt", ios::out); c....
-
Which of the following conditions evaluates to true when the letter variable contains the letter Z in either uppercase or lowercase? a. if (letter = 'Z' || letter = 'z') b. if (letter == 'Z' ||...
-
In this exercise, you will create a program that allows the user to enter an unknown number of sales amounts for each of three car dealerships: Dealership 1, Dealership 2, and Dealership 3. Use a...
-
Derive coefficients \[ C_{j k}=\frac{2}{\sqrt{ho a b}} \] using the normalization procedure given for \(W_{j k}\) by Equation 8.40. == Wik(x, y) Cik sin aja sin Yky, or Wjk (x, y) =Cjk sin x : sin...
-
Show how the parameters \(k_{i j}\) and \(m_{i j}\) are derived.
-
Derive Equations 8.54. m =mydx = = mL 5 mL = m12 myydx= m21 mamy dx = k11=EIYdx= 6 mL 7 (8.54) 4EI 6EI k12 = SEIYYdx= -k21 12EI k22=EIYdx
Study smarter with the SolutionInn App