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 President can most effectively influence the Congress by:
What is your rate in miles/hour if you tun at a speed of 2.2 miles in 20 minutes
John and mary went to the mall. Is this a sentence or fragment?
6 cakes cost to pound £2.40 how much does 10 cakes cost?
Solve for x: x2 + 8x = -1
start at 1000 create a pattern that subtract 8 from each number stop when you have five numbers
how does the slope of a road affects a persons driving
What is more permeable? Gravel, sand, or silt?
What times what equals 24
As we find with most songs, in poetry A. meanings are hidden in imprecise words. B. each couplet must rhyme. C. there's no specific point of view. D. sound and