I need some help getting this code to work.
I need to be able to Write a program that counts how many times three six-sided dice must be rolled until the values showing are all different.
Instructions:
Write a driver that generates 10 output runs.
Here is an example of two output runs.
2 6 5
count = 1
5 3 5
3 5 3
3 3 4
1 3 3
2 5 4
count = 5
Here is my code so far, I don't exactly know where and how to apply DeMorgan's law to this.
import java.util.Random;
public class P4_Icel_Murad_Rolling
{
public static void main(String[] args){
P4_Icel_Murad_Rolling obj = new P4_Icel_Murad_Rolling();
obj.rolling(10);
}
public void rolling(int number){
int counter = 0;
Random num = new Random();
for(int i = 0; i < number; i++){
int A = num.nextInt(6);
System.out.print(A + " ");
int B = num.nextInt(6);
System.out.print(B + " ");
int C = num.nextInt(6);
System.out.print(C + " ");
if((){
counter++;
}
System.out.println();
}
}
}
Try this: (I don't know hot to apply de Morgan's Laws here.)
public static void main(String[] args){
P4_Icel_Murad_Rolling obj = new P4_Icel_Murad_Rolling();
obj.rolling(10);
}
public void rolling(int number){
int counter = 1;
Random num = new Random();
for(int i = 0; i < number; i++) {
int A = num.nextInt(6) + 1;
System.out.print(A + " ");
int B = num.nextInt(6) + 1;
System.out.print(B + " ");
int C = num.nextInt(6) + 1;
System.out.print(C + "\n");
if(A == B || A == C || B == C) {
counter++;
}
System.out.println("count = " + counter);
}
}