Question: Java 1. Task: Write a Java program to solve the following problem using 1-dim arrays. Given a 1-dim array, create a second array that holds

Java
Java 1. Task: Write a Java program to solve the following problem

1. Task: Write a Java program to solve the following problem using 1-dim arrays. Given a 1-dim array, create a second array that holds two copies of each value in the original array. Have the following methods: 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 twice that returns the second array holding two copies of each value in the original array . All methods should take as input parameters the array and its size (do not use .length). Make sure that all methods are reusable. Write a driver program to call these methods and get output similar to the sample output below (use a loop). SAMPLE OUTPUT: Start ty): Y How many elements/array: a Not an integer! Try again! How many elements in the list: 3.5 Not an integer! Try again! How many elements in the 21st: 9 The original array is: 2.37 4 34 12 9 37 5 The second array is: 2.2 3 3.77.44 34 34 12 12 99 37 37 5 5 Continue ty): Y How many elements in the list: S The original array is 137 49 72 The second array 11 37 37 49 493 372 72 Coot | Vu / H

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!