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 do you check battery state of charge with a voltmeter
cupoosta [38]

Answer:

Depends on the battery and the current type.

Is it AC or DC?

Explanation:

Could you mark as brainiest.

I need it for my account

Thank you! :)

8 0
2 years ago
When you multiply monomials with the same variables, you multiply the coefficients and add the exponents!
RideAnS [48]

Answer: ok

Explanation:

this isn't a question?

3 0
2 years ago
Relay contacts that are defined as being normally open (n.o.) have contacts that are:_____.
Reptile [31]

Relay contacts that are defined as being normally open (n.o.) have contacts that are open only if  the relay coil is known to have de-energized.

<h3>What is meant by normally open contacts?</h3>

Normally open (NO) are  known to be open if there is no measure of current that is flowing through a given coil but it often close as soon as the coil is said to be energized.

Note that  Normally closed (NO) contacts are said to be closed only if the coil is said to be de-energized and open only if the coil is said to carry current or is known to have energized.

The role of relay contact is wide. The Relays are tools that are often used in the work of  switching of control circuits and it is one that  a person cannot used for power switching that has relatively bigger ampacity.

Therefore, Relay contacts that are defined as being normally open (n.o.) have contacts that are open only if  the relay coil is known to have de-energized.

Learn more about Relay contacts from

brainly.com/question/15334861
#SPJ1

8 0
1 year ago
What are the 3 dimensions that used in isometric sketches?
noname [10]

Answer:

The three dimensions shown in an isometric drawing are the height, H, the length, L, and the depth, D

Explanation:

An isometric drawing of an object in presents a pictorial projection of the object in which the three dimension, views of the object's height, length, and depth, are combined in one view such that the dimensions of the isometric projection drawing are accurate and can be measured (by proportion of scale) to draw the different views of the object or by scaling, for actual construction of the object.

5 0
3 years ago
I am having trouble understanding how I got these wrong on my test. Is there something I am missing with xor?
GuDViN [60]

Answer:

  your answer is correct

Explanation:

You have the correct mapping from inputs to outputs. The only thing your teacher may disagree with is the ordering of your inputs. They might be written more conventionally as ...

 A B Y

 0 0 1

 0 1 0

 1 0 0

 1 1 1

That is, your teacher may be looking for the pattern 1001 in the last column without paying attention to what you have written in column B.

8 0
2 years ago
Other questions:
  • Select the right answer<br>​
    8·1 answer
  • The rate at which velocity changes is called?
    5·2 answers
  • Which source would be the best to base a hypothesis upon
    9·1 answer
  • Complete the sentence to identify a useful advance in the culinary arts.
    8·1 answer
  • A low-resistance path in a circuit, commonly called a _____ can cause a circuit breaker to trip
    7·1 answer
  • What is government role in the modern American version of capitalism
    11·1 answer
  • An engine has a piston with a surface area of 17.31 in2 and can travel 3.44 inches. What is the potential change in volume, disp
    10·1 answer
  • Need help, I will give cake :))<br><br> + branliest
    14·2 answers
  • Dear sir i want to ask something about the solution of my question?
    9·1 answer
  • OSHA requires safe work practices when working around brake shoes and clutches that contain asbestos.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!