I am trying to create a code that gives me two random int. They should be even, not zero and the reminder of x/z should be zero. This is the code i tried but sometimes y==0 anyway. Something simple missing?
public static void main(String[] args){
int x;
int y=0;
Random test = new Random();
do{
x = test.nextInt((10)+1) *2;
}while(x == 0);
try{
do{
y=test.nextInt(10);
}while(x%y != 0 && y == 0);
}catch(ArithmeticException e){
}
System.out.println(x);
System.out.println(y);
}