Write a static method named quads that repeatedlyflips a coin until 4 heads in a
ID: 3611615 • Letter: W
Question
Write a static method named quads that repeatedlyflips a coin until 4 heads in a row are seen. You shoulduse a Random objectto give an equal chance to a head or a tail appearing. Each timethe coin is flipped, what is seen is displayed (H for heads, T forTails). When 4 heads in a row are flipped, a congratulatory messageis printed. Here are possible outputs of four calls to quads:T T T H T H H H H
Four heads in a row!
H H T T T H H H T T H T H H T H H H H
Four heads in a row!
T T T H H H H
Four heads in a row!
T H T H T T T T T H T H H H H
Four heads in a row!
Explanation / Answer
please rate - thanks import java.util.*; public class untitled1 {static Random generator = new Random(); public static void main(String []args) {quads(); } public static void quads() {int heads=0,n; while(headsRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.