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
Basil is installing a system in Toronto, Ontario where they are wide temperature variations. What is the TD of the system he’s i
marysya [2.9K]
In places with cold winters, space heating systems have a fundamental role in buildings. Without them, indoor temperatures would quickly become unsuitable for human occupancy. The local weather is one of the most important factors when designing a heating system; if two identical buildings are developed in Miami FL and New York City, the heating load will be much higher for the NYC property.

4 0
4 years ago
A car travells at 67.5 km\h in 120 km.how long will it take to reach the destination
Kruka [31]

mark me the brainiest here

average speed (in km/h) of a car stuck in traffic that drives 12 kilometers in 2 hours.

5 0
3 years ago
What is a system that performs different functions according to a fixed schedule?
geniusboy [140]

<u>I'm pretty sure your answer is B, because Sequential Control operates during order like a schedule</u>

Sequential Control=A control system in which the individual steps are processed in a predetermined order, progression from one sequence step to the next being dependent on defined conditions being satisfied.

Tell me if I'm incorrect but, Hope this helps!

4 0
3 years ago
Read 2 more answers
If you always follow the same five steps to get ready for school, then you are following an algorithm.
raketka [301]

Answer:

hmm true

Explanation:

becuase i think alogorthm is wht u do regurkry if i helped mark me brailist

4 0
3 years ago
Read 2 more answers
(a) What is the distinction between hypoeutectoid and hypereutectoid steels? (b) In a hypoeutectoid steel, both eutectoid and pr
Gnoma [55]

Answer:

See explanation below

Explanation:

Hypo-eutectoid steel has less than 0,8% of C in its composition.

It is composed by pearlite and α-ferrite, whereas Hyper-eutectoid steel has between 0.8% and 2% of C, composed by pearlite and cementite.

Ferrite has a higher tensile strength than cementite but cementite is harder.

Considering that hypoeutectoid steel contains ferrite at grain boundaries and pearlite inside grains whereas hypereutectoid steel contains a higher amount of cementite, the following properties are obtainable:

Hypo-eutectoid steel has higher yield strength than Hyper-eutectoid steel

Hypo-eutectoid steel is more ductile than Hyper-eutectoid steel

Hyper-eutectoid steel is harder than Hyper-eutectoid steel

Hypo-eutectoid steel has more tensile strength than Hyper-eutectoid steel.

When making a knife or axe blade, I would choose Hyper-eutectoid steel alloy because

1. It is harder

2. It has low cost

3. It is lighter

When making a die to press powders or stamp a softer metals, I will choose hypo-eutectoid steel alloy because

1. It is ductile

2. It has high tensile strength

3. It is durable

7 0
3 years ago
Read 2 more answers
Other questions:
  • Primary Creep: slope (creep rate) decreases with time
    10·1 answer
  • Create a program that calculates the monthly payments on a loan using Decimal &amp; LC Console SEE Sanple Run Attached Specifica
    14·1 answer
  • The rate at which velocity changes is called?
    5·2 answers
  • A 1 m3 rigid tank initially contains air whose density is 1.18kg/m3. The tank is connected to a high pressure supply line throug
    12·1 answer
  • Please help <br>.. <br>....<br> . .<br>....<br>...​
    13·1 answer
  • Answer the question faster please
    7·1 answer
  • The product of two factors is 4,500. If one of the factors is 90, which is the other factor?
    15·1 answer
  • Calculate the acceleration of a 2000kg single engine airlane just before take off when the thrust of the engine is 500n?
    5·1 answer
  • Which of the following is NOT associated with Urban Sprawl?
    8·1 answer
  • A composite plane wall consists of a 5-in.-thick layer of insulation (ks = 0.029 Btu/h*ft*°R) and a 0.75-in.-thick layer of sidi
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!