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

Situation, data type, objectives, familiarity, and certainty are all factors in
Apply the distributive property to factor out the greatest common factor
What is the perimeter of a rectangle with sides 10.5 ft and 7 ft?
Which of these are associated with an active lifestyle? Select the three correct answers. a.High-quality sleepB.Good body compositionC.Mental clarityD.High inte
What is your purpose when you are writing to inquire?
what are 2 benefits of using models in science
Music that incorporates native folk songs, stories and history is called:
Need help on these two questions please
How many integers from 1 to 135 have 2 as a factor?
How was Joseph Stalin viewed by the people of his nation? How do you know what the public opinion was?