I created small application where I choose five numbers randomly if they are divisible by 2 I won the game if not I lose . My question I want to tweak it .If I get three number divisible by 2 I won the game and if not I lose it .
This is code :
import java .util.Random ;
public class Boolean {
public static void main (String [] a) {
Random r = new Random ();
int [] num = new int [6];
boolean Result = true;
for ( int k = 0; k < num.length ; k++) {
num [k] = r.nextInt(100) +1 ;
if (num [k] %2 == 0 ) {
System.out.println("TRUE -"+ num[k] + "\tis divisble by 2 ." );
}else {
System.out.println("False -"+ num[k] + "\tis divisble by 2 ." );
Result = false;
}
}
if (Result ) {
System.out.println(" you won the have ");
}else {
System.out.println("you have lost the game ");
}
}
}