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
Engineering Specificaitons is ...
kvv77 [185]

"Engineering specifications" means those records which provide detailed documentation of the construction, wiring, arrangement and related engineering details of the information processing equipment.

5 0
3 years ago
Problema sobre programacion orientada a objetos!!
Alecsey [184]

Answer:If they are used to top-down programming or functional programming, which treats elements of code as precise mathematical functions, it takes .

Explanation:

8 0
3 years ago
A 0.25" diameter A36 steel rivet connects two 1" wide by .25" thick 6061-T6 Al strips in a single lap shear joint. The shear str
just olya [345]

Answer:

Option B

1025 psi

Explanation:

In a single shear, the shear area is \frac {\pi d^{2}}{4}=\frac {\pi 0.25^{2}}{4}

The shear strength=0.58\sigma_y and in this case \sigma_y=36 000 psi

Shear strength=\frac {Load}{Shear area} hence making load the subject then

Load=Shear area X Shear strength

Load=\frac {\pi 0.25^{2}}{4} \times 0.58\times 36000\approx 1025 psi

3 0
3 years ago
Why is it reasonable to say that no system is 100% efficient?​
Virty [35]

Generally, frictional losses are more predominant for the machines being not 100% efficient. This friction leads to the loss of energy in the form of heat, into the surroundings. Some of the supplied energy may be utilised to change the entropy (measure of randomness of the particles) of the system.

5 0
3 years ago
Only put coolant into your radiator when the engine is _____.
Arada [10]

Only put ciilant into ur radiator when the engine is cool (D)

5 0
3 years ago
Other questions:
  • Please describe a real situation in which you had to troubleshoot and fix the failure of a piece equipment/machine?
    5·1 answer
  • Time complexity of merge sort
    15·1 answer
  • Talc and graphite are two of the lowest minerals on the hardness scale. They are also described by terms like greasy or soapy. B
    14·1 answer
  • Technician A says that a magnetic field can be created by current flow. Technician B says that current can be induced by moving
    5·1 answer
  • Is microwave man made
    5·2 answers
  • A. A compound gear train is composed of four gears: E,F,G,H. Gear E has 15 teeth and is meshed with gear F. Gear F has 25 teeth
    11·1 answer
  • .If aligned and continuous carbon fibers with a diameter of 6.90 micron are embedded within an epoxy, such that the bond strengt
    11·1 answer
  • Contrast the electron and hole drift velocities through a 10 um (micro meter) layer of intrinsic silicon across which a voltage
    11·1 answer
  • Why do stores still sell those 1.5 volt batteries that are like three times the size of other 1.5 volt batteries. What is the po
    9·2 answers
  • 8. If you push a 2000 N weight up a ramp with 400 N of force and you raise the weight 1 meter,
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!