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

The___________states that <AGI and <BGH are congruent. A. Congruent Supplements TheoremB. Right Angles TheoremC. Vertical Angles Theorem​
Evaluate the expression 5^3 ÷ (13 − 8) × 2.
Why was Angkor Wat built?
How long did it take for Rome to be built
What is the conflict and resolution of the lottery by Shirley Jackson
What three rights is the Government supposed to protect under John Locke?
Analyze why the American troops regained their confidence by the spring of 1778. Summarize (5 sentences min.) what led to this improvement.
Teddy is preparing to sell some wooden blocks at a garage sale. Before pricing individual bags of blocks, he decides to determine the approximate number of bloc
If a train were traveling from Tennessee to South Carolina in 1850, what other state would it pass through?
What is the answer for this question?