You are writing a program to generate a random number between 0 and 1, and if it is less than .5, print heads, otherwise print tails. You have the following code so far:
import .Math;
class ExamPrep {
public static void main(String[] args){
double result = Math.random();
// LINE 6
}
}
What can you add at LINE 6 to print heads or tails depending on the value of result? Choose the correct answer:
A. if (result < .5) {
System.out.println("heads");
} else {
System.out.println("tails");
}
B. if (result < .5)
System.out.println("heads");
otherwise
System.out.println("tails");
C. if (result < .5) {
System.out.println("heads");
} or else {
System.out.println("tails");
}
D. if (result < .5)
System.out.println("heads");
or else
System.out.println("tails");