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
Sketches are a very efficient way to share ideas.<br> True<br> False
timurjin [86]

Answer:

yes

Explanation:

4 0
3 years ago
Read 2 more answers
Sawing stock to reduce its thickness is known as __________ .
rjkz [21]

Answer:

resawing

Explanation:

8 0
4 years ago
Which principle of the software engineering code of ethics has gilbert violated?.
Yuki888 [10]

Answer:

Judgement

Explanation:

Gilbert is required by the Judgement Principle to "disclose those conflicts of interest that cannot reasonably be avoided or escaped." Since Gilbert professionally believes that the software meets specifications, secures documents, and satisfies user requirements, it is not clear if he violated any principle. However, he could have informed his client of his interest in the software and also presented other software packages of different companies from which the client could make its independent choice.

7 0
3 years ago
X²-12x=0 ПЖ срочно реально решите помагие ​
nika2105 [10]

Answer:

формула pq sry i dont speak russian lol but thats the solution of the equation

4 0
3 years ago
three balls each have a mass m if a has a speed v just before a direct collision with B determine the speed of C after collision
ratelena [41]

Answer:

Vc2= V(l+e) ^2/4

Vg2= V(l-e^2)/4

Explanation:

Conservation momentum, when ball A strikes Ball B

Where,

M= Mass

V= Velocity

Ma(VA)1+ Mg(Vg)2= Ma(Va)2+ Ma(Vg)2

MV + 0= MVg2

Coefficient of restitution =

e= (Vg)2- (Va)2/(Va)1- (Vg)1

e= (Vg)2- (Va)2/ V-0

Solving equation 1 and 2 yield

(Va)2= V(l-e) /2

(Vg)2= V(l+e)/2

Conservative momentum when ball b strikes c

Mg(Vg)2+Mc(Vc)1 = Mg(Vg)3+Mc(Vc)2

=> M[V(l+e) /2] + 0 = M(Vg)3 + M(Vc) 2

Coefficient of Restitution,

e= (Vc)2 - (Vg)2/(Vg)2- (Vc)1

=> e= (Vc)2 - (Vg)2/V(l+e) /2

Solving equation 3 and 4,

Vc2= V(l+e) ^2/4

Vg2= V(l-e^2)/4

8 0
3 years ago
Read 2 more answers
Other questions:
  • 1. Copy the file Pay.java (see Code Listing 1.1) from the Student CD or as directed by your instructor. 2. Open the file in your
    10·1 answer
  • An equal-tangent sag vertical curve connects a 1% and 3% initial and final grades, respectively, and is designed for 70 mph. The
    12·1 answer
  • Material with hardness of 220 Vickers is harder than material with a hardness of 180 Vickers. a)-True b)- False
    8·1 answer
  • Air modeled as an ideal gas enters a well-insulated diffuser operating at steady state at 270 K with a velocity of 180 m/s and e
    11·1 answer
  • If you stretch a rubber hose and pluck it, you can observe a pulse traveling up and down the hose. What happens to the speed of
    10·1 answer
  • Q1. Basic calculation of the First law (2’) (a) Suppose that 150 kJ of work are used to compress a spring, and that 25 kJ of hea
    6·1 answer
  • Describe how a cavity wall works and sketch its major construction features. What aspects of cavity wall construction are most c
    5·1 answer
  • W<br>n só<br>i<br>Eo<br>E<br>find the transfer function​
    9·1 answer
  • Technician A says that 5W-30 would be better to use than 20W-50 in most vehicles in
    7·2 answers
  • A ___ is a type of purlin used as a horizontal stiffener between columns around the perimeter of a building.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!