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
Incremental software development could be very effectively used for customers who do not have a clear idea about the systems nee
avanturin [10]

<u>Software Development and Client Needs</u>

In Incremental method of software development customers who do not have a basic idea of the development process are being carried along on like other methods that will relegate them to the background until a product is ready.

With this model and structure in place, when softwares/ products are built from several stages e.g prototype, testing, and when new features are added customers are always carried along with their valuable feedback and suggested greatly considered to achieve the customers satisfactions

This model will work well for the customers/clients who does not have a clear idea on the systems needed for their operations.

In summary the incremental model combines features from the waterfall and prototyping model.

For more information on soft ware development process kindly visit

brainly.com/question/20369682

5 0
2 years ago
Pie charts should have no more than eight segments. True or False?
Pepsi [2]

Answer:

Explanation:

Pie charts generally should have no more than eight segments.

6 0
2 years ago
Read 2 more answers
Assume the impedance of a circuit element is Z = (3 + j4) Ω. Determine the circuit element’s conductance and susceptance.
djyliett [7]

Answer:

B. G = 333 mS, B = j250 mS

Explanation:

impedance of a circuit element is Z = (3 + j4) Ω

The general equation for impedance

Z = (R + jX) Ω

where

R = resistance in ohm

X = reactance

R = 3Ω  X = 4Ω

Conductance = 1/R while Susceptance = 1/X

Conductance = 1/3 = 0.333S

= 333 mS

Susceptance = 1/4 = 0.25S

= 250mS

The right option is B. G = 333 mS, B = j250 mS

8 0
2 years ago
engineering uses data from pareto charts to analyse motor faults caused during their production. Explain one advantage of using
lions [1.4K]
The advantage of a pareto chart is to make sure they have all of their tools
3 0
3 years ago
Hello Averyone Subs Chanel Me please "RezaDarmawangsa "<br>Thanks !!​
Yanka [14]

Answer:

what kind of content? I need to know

4 0
2 years ago
Other questions:
  • Suppose that a wireless link layer using a CSMA-like protocol backs off 1ms on average. A packet’s link and physical layer heade
    5·1 answer
  • A wooden cylinder (0 02 x 0 02 x 0 1m) floats vertically in water with one-third of ts length immersed. a)-Determine the density
    7·1 answer
  • Calculate total hole mobility if the hole mobility due to lattice scattering is 50 cm2 /Vsec and the hole mobility due to ionize
    5·2 answers
  • Trees grow in bulk in outward direction​
    9·1 answer
  • The three suspender bars AB, CD, and EF are made of A-36 steel and have equal cross-sectional areas of 500 mm2. Determine the av
    9·1 answer
  • Please look at the attachments and help me with these questions
    7·1 answer
  • What invention of the Middle Ages contributed to making books easily available?
    15·1 answer
  • Coving is a curved edge between a floor and a wall.<br> O True<br> O False
    13·2 answers
  • A technician is building a high-performance gaming pc. which two items should the technician focus on selecting parts for the ma
    8·1 answer
  • Which of the following situations best describes student engaged in active learning
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!