
Write a program with a main() method that asks the user to input an integer array of 10 elements.
Next, create three methods described below. From inside your main() method, call each of the
three methods described below and print out the results of the methods 2, 3, which return values.
1. printReverse() - a method that receives an array of integers, then reverses the elements of
the array and prints out all the elements from inside the method. Print all in one line
separated by commas (see sample output below). Do not print the ‘trailing’ comma!!
2. getLargest() – a method that receives an array of integers, then returns the largest integer
value in the array. Return largest integer and print from main(), not method.
3. computeTwice()- a method that receives the previously reversed array of integers, then
returns an array of integers which doubles the value of each number in the array (see the
sample output below). Return new array of integers print from main(), not method
EXAMPLE OUTPUT:
Enter a number:
22
Enter a number:
34
Enter a number:
21
Enter a number:
35
Enter a number:
12
Enter a number:
4
Enter a number:
2
Enter a number:
3
Enter a number:
99
Enter a number:
81
Here the array in reverse: 81, 99, 3, 2, 4, 12, 35, 21, 34, 22
The highest valued element: 99
The array with two times each element: [162, 198, 6, 4, 8, 24, 70, 42, 68, 44]

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images

- Write a method which does the following:a. Ask the user to enter a size of array between 2 to 10.b. Based on the size entered, write a loop which asks the user to fill values into an integer array. Printthe array contents using Arrays.toString().c. For this integer array, write a logic that returns true if there exists a place to split the array such thatthe sum of the numbers on one side is equal to the sum of the numbers on the other. Otherwisereturn false.d. Examples:If the array is {1, 1, 1, 2, 1} then return true.If the array is {2, 1, 1, 2, 1} then return falseIf the array is {10, 10} then return true must include a try catch statementarrow_forwardShow your code and console with the exact sample run. Thankyouarrow_forwardYou are given an array of n integers. Write a java method that splitsthe numbers of the array into two equal groups so that the GCD of all numbers in the second group is equal to one and the GCD of all numbers in the first group is not one. After splitting the numbers display the resulting groups as shown in the sample run below. Note: 1. The array has even size. 2. All elements of the array are less than 100. You are not allowed to define new arrays. 3. 4. You are not allowed to definenew methods or use methods from java libraries. Sample run of the method: Inputarray: (6,7,9,4,3,2} Output Group two: (7,9,3} Group one: (2,4,6} I Ignore Order of numbers. Order is not important //Ignore Order of numbers. Order is not importantarrow_forward
- Could i get help with this java program where you have to write a static method which reverses an integer array. The array will be a parameter to the method. Put the method in a Test class Your method would be called as follows int [] num = {2, 3, 5, 7, 11, 13, 17}; // Call the method to reverse the array Test.reverse(num); Your method should not print anything. It will be called by the following program: import java.util.Scanner; public class Main { public static void main(String [] args) { // Create a scanner object Scanner in = new Scanner(System.in); System.out.print("How many numbers: "); int len = in.nextInt(); int [] num = new int[len]; System.out.print("Enter " + len + " numbers: "); for(int i = 0; i < num.length; i++) num[i] = in.nextInt(); Test.reverse(num); System.out.print("The numbers reversed are:"); for(int i = 0; i < num.length; i++) System.out.print(" " + num[i]); System.out.println(); } } This program will read in the array and use your method to reverse the…arrow_forwardFor Java. Create a program that can read N integer numbers, store them in an array and then use a method to calculate and return the average of all numbers. Refer to photo.arrow_forward1. Write a program that calls a method that takes a character array as a parameter (you can initialize an array in the main method) and returns the number of vowels in the array. Partial program is given below. public class CountVowels{ public static void main(String[] args){ char[] arr= System.out.print("There are "+vowels(arr)+" vowels in the array");arrow_forward
- Define an empty array with 4 elements inside the "main" method. The value '-1' from the user to this arrayRecord the numbers entered by the user in order until they arrive. User array with 4 elementsAfter adding, write the required method so that it can continue adding elements. This method will take the array as a parameter, expand the size of the array and return the array variable.will return. Using this method you defined, the user can add elements to the array.make it continue.arrow_forwardNeeds to be written in java: Write a program with a main() method that asks the user to input an integer array of 10 elements.Next, create three methods described below. From inside your main() method, call each of thethree methods described below and print out the results of the methods 2, 3, which return values.1. printReverse() - a method that receives an array of integers, then reverses the elements ofthe array and prints out all the elements from inside the method. Print all in one lineseparated by commas (see sample output below).2. getLargest() – a method that receives an array of integers, then returns the largest integervalue in the array. (print result from main())3. computeTwice()- a method that receives the previously reversed array of integers, thenreturns an array of integers which doubles the value of each number in the array (see thesample output below). (print result from main())Sample output:Enter a number:22Enter a number:34Enter a number:21Enter a number:35Enter a…arrow_forward2. Write a method that takes a rectangular two-dimensional array of type int and returns a valu of type int. The method returns the number of rows with negative sum. A row has a negative s if the sum of all its elements is less than 0. public static int countNegativeSum(int[][] in) Taken array Result 1 -3 17 -5 -5 14 -5 -2 30 -19 -8 -8 1 1 3 -1 -4 78 8 -3 -5 -1 -1 3 -4arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





