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
Technician A says independent shops are not affiliated with vehicle manufacturers, but it is easy for technicians who work in th
KatRina [158]

Answer:

b

Explanation:

i did it yeater dayajsbs

8 0
3 years ago
melinda is using a rectangular brass bar in a sculpture she is creating. the brass bar has a length that is 4 more than 3 times
lawyer [7]

Answer:

180 x 60 inches

Width = 60 inches

Length = 180 inches

Explanation:

Given

Let L = Length

W = Width

P = Perimeter

Length = 3 * Width

L = 3W

Perimeter of Brass = 480 inches

P = 480

Perimeter is given as 2(L + W);

So, 2 (L + W) = 480

L + W = 480/2

L + W = 240

Substitute 3W for L; so,

3W + W = 240

4W = 240

W = 240/4

W = 60 inches

L = 3W

L = 3 * 60

L = 180 inches

6 0
3 years ago
Read 2 more answers
A furnace wall is to be built of 20-cm firebrick and building (structural) brick of same thickness. The thermal conductivities o
Norma-Jean [14]

Answer:

q=2313.04W/m^2

T=690.86°C

Explanation:

Given that

Thickness t= 20 cm

Thermal conductivity of firebrick= 1.6 W/m.K

Thermal conductivity of structural brick= 0.7 W/m.K

Inner temperature of firebrick=980°C

Outer temperature of structural brick =30°C

We know that thermal resistance

R=\dfrac{t}{KA}

These are connect in series

R=\left(\dfrac{t}{KA}\right)_{fire}+\left(\dfrac{t}{KA}\right)_{struc}

R=\dfrac{0.2}{1.6A}+\dfrac{0.2}{0.7A}\ K/W

R=\dfrac{23}{56A}\ K/W

Heat transfer

Q=\dfrac{\Delta T}{R}

Q=56A\times \dfrac{980-30}{23}\ W

So heat flux

q=2313.04W/m^2

Lets temperature between interface is T

Now by equating heat in both bricks

\dfrac{980-T}{\dfrac{0.2}{1.6A}}=\dfrac{T-30}{\dfrac{0.2}{0.7A}}

So T=690.86°C

6 0
3 years ago
A clean machine is a _______________ machine.
solniwko [45]
A clean machine is a clean machine :-)
4 0
3 years ago
A 100 ft long steel wire has a cross-sectional area of 0.0144 in.2. When a force of 270 lb is applied to the wire, its length in
blondinia [14]

Answer:

(a) The stress on the steel wire is 19,000 Psi

(b) The strain on the steel wire is 0.00063

(c) The modulus of elasticity of the steel is 30,000,000 Psi

Explanation:

Given;

length of steel wire, L = 100 ft

cross-sectional area, A = 0.0144 in²

applied force, F = 270 lb

extension of the wire, e = 0.75 in

<u>Part (A)</u> The stress on the steel wire;

δ = F/A

   = 270 / 0.0144

δ  = 18750 lb/in² = 19,000 Psi

<u>Part (B)</u> The strain on the steel wire;

σ = e/ L

L = 100 ft = 1200 in

σ = 0.75 / 1200

σ = 0.00063

<u>Part (C)</u> The modulus of elasticity of the steel

E = δ/σ

   = 19,000 / 0.00063

E = 30,000,000 Psi

4 0
3 years ago
Other questions:
  • The natural variation of a process relative to the variation allowed by the design specifications is known as
    15·1 answer
  • What is the one change that golden expects to see in public transportation?
    12·1 answer
  • The creation of designer drugs is outpacing the ability of society to enact laws to prohibit them. Many of these substances have
    11·1 answer
  • A cylinder with a piston restrained by a linear spring contains 2 kg of carbon dioxide at 500 kPa and 400°C. It is cooled to 40°
    7·1 answer
  • Think of an employee object. What are several of the possible states that the object may have over time?
    6·1 answer
  • Describe in your own words the three strengthening mechanisms
    7·1 answer
  • Question
    8·1 answer
  • What happens to the electrolyte, during discharging?
    9·1 answer
  • Can I put a fork in electric socket?
    9·2 answers
  • What is resonance as in ultrasound waves formation using magnetostriction method​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!