Answer:
Here is the additional method you need to write:
public static int [] newArrayNumbers (int [] numbers){
int [] newArray = new int[10];
for (int i=0; i<numbers.length; i++){
newArray[i]=numbers[i];
}
newArray[9]=10;
return newArray;
}
The complete code is given in the explanation section
Step-by-step explanation:
import java.util.Arrays;
public class NewQues{
public static void main(String[] args) {
int [] numbers = {99,56,103,9,31,63,81,92,13};
int m = maximum (numbers);
int n = minimum (numbers);
System.out.println("max ="+ m);
System.out.println("min ="+ n);
System.out.println(Arrays.toString(newArrayNumbers(numbers)));
}
public static int maximum (int [] numbers){
int i=0;
int max;
max = numbers[i];
for (i = 1; i < numbers.length; i++){
if (numbers[i]> max)
{
max = numbers[i];
}
}
return(max);
}
public static int minimum (int [] numbers){
int i=0;
int min;
min = numbers[i];
for (i = 1; i < numbers.length; i++){
if (numbers[i]< min)
{
min = numbers[i];
}
}
return(min);
}
public static int [] newArrayNumbers (int [] numbers){
int [] newArray = new int[10];
for (int i=0; i<numbers.length; i++){
newArray[i]=numbers[i];
}
newArray[9]=10;
return newArray;
}
}
This for statement here does the work for you. assigning the values in the first array to the second array.
for (int i=0; i<numbers.length; i++){
newArray[i]=numbers[i];
}
The second logic is, since you knew the first array had 9 elements, you create the second to have 10 elements so you can assign the element at the last index (9) the value of ten as required by the question