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
What material property would still cause strain in a strain gauge that is positionedperpendicular to the direction of force if i
svetlana [45]

Answer:

oof

Explanation:

I don't know but please don't report me

I am trying to do a challenge

Thank you-

If you don't report me!

5 0
3 years ago
Consider air entering a heated duct at P1 = 1 atm and T1 = 288 K. Ignore the effect of friction. Calculate the amount of heat pe
Ne4ueva [31]

Answer:

The solution for the given problem is done below.

Explanation:

M1 = 2.0

\frac{p1}{p*} = 0.3636

\frac{T1}{T*} = 0.5289

\frac{T01}{T0*} = 0.7934

Isentropic Flow Chart:  M1 = 2.0 , \frac{T01}{T1} = 1.8

T1 = \frac{1}{0.7934} (1.8)(288K) = 653.4 K.

In order to choke the flow at the exit (M2=1), the above T0* must be stagnation temperature at the exit.

At the inlet,

T02= \frac{T02}{T1}T1 = (1.8)(288K) = 518.4 K.

Q= Cp(T02-T01) = \frac{1.4(287 J / (Kg.K)}{1.4-1}(653.4-518.4)K = 135.7*10^{3} J/Kg.

5 0
3 years ago
Read 2 more answers
An AX ceramic compound has the rock salt crystal structure. If the radii of the A and X ions are 0.137 and 0.241 nm, respectivel
Tju [1.3M]

Answer:

c) 1.75 g/cm³

Explanation:

Given that

Radii of the A ion, r(c) = 0.137 nm

Radii of the X ion, r(a) = 0.241 nm

Atomic weight of the A ion, A(c) = 22.7 g/mol

Atomic weight of the X ion, A(a) = 91.4 g/mol

Avogadro's number, N = 6.02*10^23 per mol

Solution is attached below

3 0
3 years ago
I logged on today to work on my makeup work. <br> A: True<br> B: False
Lelu [443]
True I don’t really know.
7 0
3 years ago
Read 2 more answers
Water at atmospheric pressure boils on the surface of a large horizontal copper tube. The heat flux is 90% of the critical value
masya89 [10]

Answer:

The tube surface temperature immediately after installation is 120.4°C and after prolonged service is 110.8°C

Explanation:

The properties of water at 100°C and 1 atm are:

pL = 957.9 kg/m³

pV = 0.596 kg/m³

ΔHL = 2257 kJ/kg

CpL = 4.217 kJ/kg K

uL = 279x10⁻⁶Ns/m²

KL = 0.68 W/m K

σ = 58.9x10³N/m

When the water boils on the surface its heat flux is:

q=0.149h_{fg} \rho _{v} (\frac{\sigma (\rho _{L}-\rho _{v})}{\rho _{v}^{2} }  )^{1/4} =0.149*2257*0.596*(\frac{58.9x10^{-3}*(957.9-0.596) }{0.596^{2} } )^{1/4} =18703.42W/m^{2}

For copper-water, the properties are:

Cfg = 0.0128

The heat flux is:

qn = 0.9 * 18703.42 = 16833.078 W/m²

q_{n} =uK(\frac{g(\rho_{L}-\rho _{v})     }{\sigma })^{1/2} (\frac{c_{pL}*deltaT }{c_{fg}h_{fg}Pr  } \\16833.078=279x10^{-6} *2257x10^{3} (\frac{9.8*(957.9-0.596)}{0.596} )^{1/2} *(\frac{4.127x10^{3}*delta-T }{0.0128*2257x10^{3}*1.76 } )^{3} \\delta-T=20.4

The tube surface temperature immediately after installation is:

Tinst = 100 + 20.4 = 120.4°C

For rough surfaces, Cfg = 0.0068. Using the same equation:

ΔT = 10.8°C

The tube surface temperature after prolonged service is:

Tprolo = 100 + 10.8 = 110.8°C

8 0
3 years ago
Other questions:
  • An n- channel enhancement- mode MOSFET with 50 nm thick HfO2 high- k gate dielectric (Pr = 25) has a flat band voltage of 0.5 V,
    5·1 answer
  • What could happen in the aviation
    5·1 answer
  • Summarize three attributes that are important for an engineer to possess.
    13·1 answer
  • Prelest! Introduction to Engineering and Technology 1 Select the correct answer. What technological invention allowed for the pr
    5·1 answer
  • Please help been stuck on this for a couple minutes
    5·1 answer
  • your friend's parents are worried about going over their budget for th month. Which expense would you suggest is NOT a need?
    9·1 answer
  • Their game off badminton is always on Tuesday
    11·1 answer
  • For many people in 3D modeling copyrights and licensing allow them to earn a living.
    12·1 answer
  • The Environmental Protection Agency (EPA) has standards and regulations that says that the lead level in soil cannot exceed the
    13·1 answer
  • Select the correct answer. Which of the following devices is a simple machine? A.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!