hajaghori hajaghori
  • 04-02-2021
  • Computers and Technology
contestada

write a method called threeHeads that repeatedly flips a coin until a coin

Respuesta :

hacker00100120
hacker00100120 hacker00100120
  • 04-02-2021

Answer:

public void threeHeads() {

Random r = new Random();

int count = 0;

while(count < 3) {

boolean head = r.nextBoolean();

if(head) {

System.out.print("H ");

count++;

} else {

System.out.print("T ");

count = 0;

}

}

System.out.println("\nThree heads in a row!");

}

Explanation:

Use GitHub

Answer Link

Otras preguntas

Which two numbers have a difference of 5 and a product of 3.36???
what other areas beside egypt did the new kingdom pharoahs conquer
what other areas beside egypt did the new kingdom pharoahs conquer
If you are writing a persuasive essay in favor of banning vending machines in schools, which is a counterargument you might anticipate?
write words to match the expression. 24- ( 6+3)
what other areas beside egypt did the new kingdom pharoahs conquer
which city was located nearest the nile river delta
write words to match the expression. 24- ( 6+3)
write words to match the expression. 24- ( 6+3)
If you are writing a persuasive essay in favor of banning vending machines in schools, which is a counterargument you might anticipate?