Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

coding in java Define a method named coinflip that takes a Random object and returns 'Heads or Tails' according to a tandom value 1 or

coding in java
image text in transcribed
Define a method named coinflip that takes a Random object and returns 'Heads" or "Tails' according to a tandom value 1 or 0. Assume the Value 1 represents "Heads" and 0 represents "Tais". Then, write a main program that rends the desired number of coinflips as an input, calls method coinfip() repeatedly according to the number of coin fips, and outputs the results. Assume the input is a value greater than 0 Ex. If the random object is created with a seed value of 2 and the input is: the output is: Heada Tas a Hends Note. For testing purposes. a Random object is created in the main0 method using a pseudo.random number generator with a fxed seed value. The program uses a seed value of 2 during development, but when submitted, a different seed value may be used for each test case The program must define and call the following method public statle string coinfllp(Randon rand) LabProgram java Coad sefaut template. 1 inoort Java. otilisconner; 2 inport jovs. vtili.aandon; 3 . public claws Laberogran f I. Deflie your hethou here % public static vold main (Stringt) arts) if Scanner sonr - new Scanner ( System, in)s flandoe rand - new Randon(2)i // Seed used in devetom nodr. II Add more warlables as needed \% Tope your cooe nere. % 14 1 isic} Run your program as often as youd like, before submitting for grading Belaw. type any needed input values in the first box, then click Run program and observe the programs outbut in the second box

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions