This code generates a 3 X 5 2d array. I need to get the users input and replace all the generated values that are less than the users input to 100. Running this code does everything I need but I can't figure out how to get the users input to compare itself to the random values and determine if it is less to change it to 100.
import java.util.*;
public class secondArray {
public static void main(String[] args) {
int[][] array2 = new int[3][5];
Random rand = new Random();
Scanner input = new Scanner(System.in);
for(int r = 0; r < array2.length; r++) {
for( int c = 0; c < array2[r].length; c++) {
array2[r][c] = rand.nextInt(50-20 +1)+20;
}
}
System.out.println("The first array is: ");
for(int r = 0; r < array2.length; r++) {
for( int c = 0; c < array2[r].length; c++) {
System.out.print(array2[r][c] + " ");
}
System.out.println();
}
System.out.println("\nEnter a number for x: ");
int x;
x = input.nextInt();
System.out.println("\nArray after changing numbers less than "+ x +" :");
}
}