1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Deffense [45]
3 years ago
9

In javaWrite a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the out

put is either heads or tails. Assume the input is a value greater than 0.Ex: If the input is 3, the output is:tails heads headsFor reproducibility needed for auto-grading, seed the program with a value of 2. In a real program, you would seed with the current time. In that case, every program's output would be different, which is what is desired but can't be auto-graded.Note: A common student mistake is to create an instance of Random before each call to rand.nextInt(). But seeding should only be done once, at the start of the program, after which rand.nextInt() can be called any number of times.Your program must define and call the following method that returns "heads" or "tails".public static String HeadsOrTails(Random rand)
Engineering
1 answer:
Pavel [41]3 years ago
7 0

Answer:

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

import java.util.*;

public class FlipCoin

{

public static void main(String[] args)

{

// Declare Scanner

Scanner input = new Scanner (System.in);

int flips;

// Prompt to enter number of toss or flips

System.out.print("Number of Flips: ");

flips = input.nextInt();

if (flips > 0)

{

HeadsOrTails();

}

}

}

public static String HeadsOrTails(Random rand)

{

// Simulate the coin tosses.

for (int count = 0; count < flips; count++)

{

rand = new Random();

if (rand.nextInt(2) == 0) {

System.out.println("Tails"); }

else {

System.out.println("Heads"); }

rand = 0;

}

}

You might be interested in
How does the map scale help to interpret the map?
krok68 [10]

Map scale refers to the relationship (or ratio) between distance on a map and the corresponding distance on the ground. For example, on a 1:100000 scale map, 1cm on the map equals 1km on the ground.

6 0
3 years ago
Read 2 more answers
Are engineers needed in today’s society ? Why or why not ? I need a short three paragraph essay !!! Please help me !!!
masha68 [24]
Of course they are needed because without them the society wouldn’t be as nice as it is right now and plus there would be no more buildings ! :)
8 0
3 years ago
The denominator of a fraction is 4 more than the numenator. If 4 is added to the numenator and 7 is added to the denominator, th
kati45 [8]

Answer:

\frac{3}{7}

Explanation:

Lets take the numerator of the fraction to be = x

So the denominator of the fraction is 4 more than the numerator = x+4

The fraction is ;\frac{x}{4+x}

Now add 4 to the numerator and add 7 to the denominator as;

\frac{x+4}{4+x+7} =\frac{x+4}{x+11}

This new fraction is equal to 1 half =1/2

write the equation as;

\frac{x+4}{x+11} =\frac{1}{2}

perform cross-product

2(x+4 )=1( x+11 )

2x+8 = x + 11

2x-x = 11-8

x=3

The original fraction is;  

\frac{x}{4+x} =\frac{3}{3+4} =\frac{3}{7}

3 0
2 years ago
Quinn’s relatives relayed a story about putting on a headset and seeing a digital world that they could walk around in and explo
Kryger [21]

Answer:

I know it is C)Virtual reality

Explanation:

Look at the clues

story about putting on a headset ( virtual reality head set!)

seeing a digital world (A virtual reality world)

they could walk around in (Fake walking you are basically jogging in place)

explore in order to see what ancient Benin looked like (Looking at a real place only digitally)

as if they were really there ( they think they are actually there)

The only reason I know all of this is because I have done virtual reality multiple times and I LOVED it SUPER fun ( I was doing archery) :) Hope this helps!

6 0
2 years ago
Read 2 more answers
Question # 3
tino4ka555 [31]

Answer:

I think it's False.

Apologies if I am wrong.

4 0
3 years ago
Read 2 more answers
Other questions:
  • 11 Notează, în caiet, trăsăturile personajelor ce se pot
    13·1 answer
  • An electronic device dissipating 25 W has a mass of 20 g and a specific heat of 850 J/kg·0K. The device is lightly used, and it
    9·1 answer
  • A contractor needs to excavate 50,000 yd3 of silty clay and haul it with Caterpillar 69C dump trucks. Each truck can carry 30.9
    13·1 answer
  • Design an Armstrong indirect FM modulator to generate an FM signal with a carrier frequency 98.1 MHz and a frequency deviation △
    15·1 answer
  • Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's
    11·2 answers
  • A pool of contaminated water is lined with a 40 cm thick containment barrier. The contaminant in the pit has a concentration of
    11·1 answer
  • The use of zeroes after a decimal point are an indicator of accuracy. a)True b)- False
    7·1 answer
  • WHICH TASK BEST FITS THE ROLE OF A DESIGN ENGINEER ?
    7·1 answer
  • You have a 12 volt power source running through a circuit that has 3kΩ of resistance, how many amps (in mA) can flow through the
    15·1 answer
  • Time left 0:35:32 Three steel rod (E = 200 GPa) supports 36 KN Load P. Each of the rods AB and CD has a 200 mm? cross- sectional
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!