wins=0; losses=0; cars[0]=0; cars[1]=0; cars[2]=0; montyElim=0; int i = 0; while (i< runs) { //the nuber in the box (it changes in the alternate mode) startRun(); i++; } public void startRun() { car = (random.nextInt()%3+3)%3; cars[car]++; if(original) {//if monty hall knows what door the car is in if(change) {//if the contestant is switching their door if(car > 0) {//if the car is not in the contestancts door (door 2 or 3) (presumably monty will eliminate the door with the goat) wins++; carIm.setVisible(true); } else{//if the car is in the contestants door (door 1) losses++; goat.setVisible(true); } } else { //if the contestant is keeping their original door if(car>0) { //if the car is in door 2 or 3 (presumably monty will eliminate the door with the goat) losses++; goat.setVisible(true); } else {//if the car is in door 1 wins++; carIm.setVisible(true); } } } else { //if monty doesn't know where the car is if(change) { // if the contestant swithcs doors if(car==0) { //if the car is in door 1 losses++; goat.setVisible(true); } else {//if the car is in door 2 or 3 if((random.nextInt()%2+2)%2>0) { //if monty eliminates a goat wins++; carIm.setVisible(true); } else { //if monty eliminates the car runs++; montyElim++; } } }else {//contestant keep their door if(car==0) { //the car is in door 1 wins++; carIm.setVisible(true); } else { //the car is in 2 or 3 if((random.nextInt()%2+2)%2>0) { losses++; goat.setVisible(true); } else { // if monty eliminates the car runs++; montyElim++; } } } }