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
At the instant under consideration, the hydraulic cylinder AB has a length L = 0.75 m, and this length is momentarily increasing
Inessa [10]

Answer:

vB = - 0.176 m/s   (↓-)

Explanation:

Given

(AB) = 0.75 m

(AB)' = 0.2 m/s

vA = 0.6 m/s

θ = 35°

vB = ?

We use the formulas

Sin θ = Sin 35° = (OA)/(AB) ⇒  (OA) = Sin 35°*(AB)

⇒   (OA) = Sin 35°*(0.75 m) = 0.43 m

Cos θ = Cos 35° = (OB)/(AB) ⇒  (OB) = Cos 35°*(AB)

⇒   (OB) = Cos 35°*(0.75 m) = 0.614 m

We apply Pythagoras' theorem as follows

(AB)² = (OA)² + (OB)²

We derive the equation

2*(AB)*(AB)' = 2*(OA)*vA + 2*(OB)*vB

⇒  (AB)*(AB)' = (OA)*vA + (OB)*vB

⇒  vB = ((AB)*(AB)' - (OA)*vA) / (OB)

then we have

⇒  vB = ((0.75 m)*(0.2 m/s) - (0.43 m)*(0.6 m/s) / (0.614 m)

⇒  vB = - 0.176 m/s   (↓-)

The pic can show the question.

7 0
3 years ago
Read 2 more answers
the tire restraining device or barrier shall be removed immediately from service for any of these defects except
lora16 [44]

Restraining devices and barriers shall be visually inspected on the rim wheel components or sudden release of contained air.

Restraining device means an apparatus such as a <em>cage, rack, assemblage of bars and other components</em> that will constrain all rim wheel components.

Restraining devices and barriers shall be visually inspected on the rim wheel components or sudden release of contained air. Any restraining device or barrier exhibiting damage such as the following defects shall be immediately removed from service.

Find out more on Restraining devices at: brainly.com/question/24647450

5 0
2 years ago
An insulated, vertical piston-cylinder device initially contains 10kg of water, 6kg of which is in the vapor phase. The mass of
Alexeev081 [22]

Answer:

a)120C

b)29kg

Explanation:

Hello!

To solve this exercise follow the steps below

1. we will call 1 the initial state, 2 the steam that enters and 3 the final state

2. We find the quality of the initial state, dividing the mass of steam by the total mass.

q1=\frac{6kg}{10kg} =0.6

3 Find the internal energy in the three states using thermodynamic tables

note:Through laboratory tests, thermodynamic tables were developed, these allow to know all the thermodynamic properties of a substance (entropy, enthalpy, pressure, specific volume, internal energy etc ..)  

through prior knowledge of two other properties such as pressure and temperature.  

u1=IntEnergy(Water;x=0,6(quality);P=200kPa) =1719KJ/kg

u2=IntEnergy(Water;t=350;P=5000kPa) =2808KJ/kg

u3=IntEnergy(Water;x=1;P=200kPa) =2529KJ/kg

4. use the internal energy and pressure to find the temperature in state 3, using thermodynamic tables

T3=Temperature(Water;P=200kPa;u=u3=2529KJ/kg)=120C

5. Use the first law of thermodynamics in the system, it states that the initial energy in a system must be equal to the final

m1u1+m2u2=(m1+m2)u3

where

m1=inital mass=10kg

m2=the mass of the steam that has entered.

solve for m2

(m1)(u1-u3)=(m2)(u3)-(m2)(u2)

m2=m1\frac{u1-u3}{u3-u2} =10\frac{1719-2529}{2529-2808} =29kg

7 0
3 years ago
¿Qué es la masonería?​
timofeeve [1]

Answer: freemasonry is Being a Mason is about a father helping his son make better decisions; a business leader striving to bring morality to the workplace; a thoughtful man learning to work through tough issues in his life.

Explanation:

3 0
3 years ago
Write a class named FBoard for playing a game, where player x is trying to get her piece to row 7 and player o is trying to make
OverLord2011 [107]

Answer:

12345=V

Explanation:

7 0
3 years ago
Other questions:
  • A cylindrical bar of steel 10.1 mm (0.3976 in.) in diameter is to be deformed elastically by application of a force along the ba
    15·1 answer
  • Define an ADT for a two-dimensional array of integers. Specify precisely the basic operations that can be performed on such arra
    5·1 answer
  • Determine the output torque To????????p????????, the speed reduction ratio of the transmission R, the tangential loads imposed o
    13·2 answers
  • A natural-draft cooling tower receives 250,000 ft3/min of air at standard atmospheric pressure, 70oF, and 45 percent relative hu
    8·1 answer
  • 11. Technicians A and B are discussing
    12·1 answer
  • What can be used to relieve stress in a weld.
    12·2 answers
  • ) If the blood viscosity is 2.7x10-3 Pa.s, length of the blood vessel is 1 m, radius of the blood vessel is 1 mm, calculate the
    13·1 answer
  • What technology has been used for building super structures​
    11·1 answer
  • Identify the prefixes used in the International System of
    15·1 answer
  • How do we infer that there is
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!