Answer:
// Program in Java
import java.util.Arrays;
import java.util.Scanner;
public class Integers {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
int [] numbers = new int [10];
for(int i=0;i<numbers.length;i++)
{
System.out.print("Enter a number:");
numbers[i]=input.nextInt();
}
printReverse(numbers);
System.out.println("The highest number is "+getLargest(numbers));
System.out.println("The array with two times the numbers: "+ Arrays.toString(computeTwice(numbers)));
input.close();
}
public static void printReverse(int [] numbers)
{
int [] revNumbers = new int[numbers.length];
for(int i = numbers.length -1; i >= 0; i--)
{
revNumbers[numbers.length - 1 -i] = numbers[i];
}
System.out.println("Here are your numbers in reverse: "+Arrays.toString(revNumbers));
}
private static int getLargest(int[] numbers) {
int max = numbers[0];
for(int i=1;i<numbers.length;i++) {
max = Math.max(numbers[i],max);
}
return max;
}
public static int[] computeTwice(int[] numbers) {
for(int i = 0; i < numbers.length; i++)
{
numbers[i] = numbers[i] * 2;
}
return numbers;
}
}
Step-by-step explanation:
- Initialize an array and loop through it to get values from the user.
- Call the printReverse method by passing the array as an argument.
- Inside the printReverse method, run the loop in reverse order.
- Call the getLargest method to print the highest number that uses Math.max function.
- Call the computeTwice method to print the array with 2 times the original number in the array.