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
Luden [163]
3 years ago
10

java Write a program that simulates tossing a coin. Prompt the user for how many times to toss the coin. Code a method with no p

arameters that randomly returns either the String "heads"or the string "tails". Call this method in main as many times as requested and report the results.
Engineering
2 answers:
igomit [66]3 years ago
5 0

Answer:

The source code to this question has been attached to this response. Please download it and go through the code.

The source code contains comments explaining important segments of the code. Kindly read the comments carefully for better readability and understandability of the code.

Download java
max2010maxim [7]3 years ago
4 0

Answer:

The solution code is written in Java.

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        Scanner inNum = new Scanner(System.in);
  4.        System.out.print("Enter number of toss: ");
  5.        int num = inNum.nextInt();
  6.        for(int i=0; i < num; i++){
  7.            System.out.println(toss());
  8.        }
  9.    }
  10.    public static String toss(){
  11.        String option[] = {"heads", "tails"};
  12.        Random rand = new Random();
  13.        return option[rand.nextInt(2)];
  14.    }
  15. }

Explanation:

Firstly, we create a function <em>toss()</em> with no parameter but will return a string (Line 14). Within the function body, create an option array with two elements, "heads" and "tails" (Line 15). Next create a Random object (Line 16) and use <em>nextInt()</em> method to get random value either 0 or 1. Please note we need to pass the value of 2 into <em>nextInx() </em>method to ensure the random value generated is either 0 or 1.  We use this generate random value as an index of <em>option </em>array and return either "heads" or "tails" as output (Line 17).

In the main program, we create Scanner object and use it to prompt user to input an number for how many times to toss the coin (Line 6 - 7). Next, we use the input num to control how many times a for loop should run (Line 9). In each round of the loop, call the function <em>toss() </em>and print the output to terminal (Line 10).  

You might be interested in
The Clausius inequality expresses which of the following laws? i. Law of Conservation of Mass ii. Law of Conservation of Energy
DanielleElmas [232]

Answer:

(iv) second law of thermodynamics

Explanation:

The Clausius  inequality expresses the second law of thermodynamics it applies to the real engine cycle.It is defined as the cycle integral of change in entropy of a reversible system is zero. It is nothing but mathematical form of second law of thermodynamics . It also states that for irreversible process the cyclic integral of change in entropy is less than zero

3 0
3 years ago
░░░░░░░░░░░░░░░░░░░▄▀▐░░░▌
allsm [11]

Answer:

wow

Explanation:

that's so cute!!!!!!!!

3 0
2 years ago
The elevation of the end of the steel beam supported by a concrete floor is adjusted by means of the steel wedges E and F. The b
Wewaii [24]

Answer:

a) P ≥ 22.164 Kips

b) Q = 5.4 Kips

Explanation:

GIven

W = 18 Kips

μ₁ = 0.30

μ₂ = 0.60

a) P = ?

We get F₁  and F₂ as follows:

F₁ = μ₁*W = 0.30*18 Kips = 5.4 Kips

F₂ = μ₂*Nef = 0.6*Nef

Then, we apply

∑Fy = 0   (+↑)

Nef*Cos 12º -  F₂*Sin 12º = W

⇒   Nef*Cos 12º -  (0.6*Nef)*Sin 12º = 18

⇒   Nef = 21.09 Kips

Wedge moves if

P ≥ F₁ + F₂*Cos 12º + Nef*Sin 12º

⇒  P ≥ 5.4 Kips + 0.6*21.09 Kips*Cos 12º + 21.09 Kips*Sin 12º

⇒  P ≥ 22.164 Kips

b) For the static equilibrium of base plate

Q = F₁ = 5.4 Kips

We can see the pic shown in order to understand the question.

7 0
3 years ago
Read 2 more answers
For a fluid with a Prandtl Number of 1000.0, the hydrodynamic layer is thinner than the thermal boundary layers. a) True b) Fals
kvv77 [185]

Answer:

(b)False

Explanation:

Given:

 Prandtl number(Pr) =1000.

We know that   Pr=\dfrac{\nu }{\alpha }

  Where \nu is the molecular diffusivity of momentum

             \alpha is the molecular diffusivity of heat.

 Prandtl number(Pr) can also be defined as

    Pr=\left (\dfrac{\delta }{\delta _t}\right )^3

Where \delta is the hydrodynamic boundary layer thickness and \delta_t is the thermal boundary layer thickness.

So if Pr>1 then hydrodynamic boundary layer thickness will be greater than thermal boundary layer thickness.

In given question Pr>1 so  hydrodynamic boundary layer thickness will be greater than thermal boundary layer thickness.

So hydrodynamic layer will be thicker than the thermal boundary layer.

8 0
3 years ago
A hydraulic jump is induced in an 80 ft wide channel.The water depths on either side of the jump are 1 ft and 10 ft.Please calcu
krek1111 [17]

Answer:

a) 42.08 ft/sec

b) 3366.33 ft³/sec

c) 0.235

d) 18.225 ft

e) 3.80 ft

Explanation:

Given:

b = 80ft

y1 = 1 ft

y2 = 10ft

a) Let's take the formula:

\frac{y2}{y1} = \frac{1}{5} * \sqrt{1 + 8f^2 - 1}

10*2 = \sqrt{1 + 8f^2 - 1

1 + 8f² = (20+1)²

= 8f² = 440

f² = 55

f = 7.416

For velocity of the faster moving flow, we have :

\frac{V_1}{\sqrt{g*y_1}} = 7.416

V_1 = 7.416 *\sqrt{32.2*1}

V1 = 42.08 ft/sec

b) the flow rate will be calculated as

Q = VA

VA = V1 * b *y1

= 42.08 * 80 * 1

= 3366.66 ft³/sec

c) The Froude number of the sub-critical flow.

V2.A2 = 3366.66

Where A2 = 80ft * 10ft

Solving for V2, we have:

V_2 = \frac{3666.66}{80*10}

= 4.208 ft/sec

Froude number, F2 =

\frac{V_2}{g*y_2} = \frac{4.208}{32.2*10}

F2 = 0.235

d) El = \frac{(y_2 - y_1)^3}{4*y_1*y_2}

El = \frac{(10-1)^3}{4*1*10}

= \frac{9^3}{40}

= 18.225ft

e) for critical depth, we use :

y_c = [\frac{(\frac{3366.66}{80})^2}{32.2}]^1^/^3

= 3.80 ft

7 0
3 years ago
Read 2 more answers
Other questions:
  • Run the program and observe the output to be: 55 4 250 19. Modify the numsInsert function to insert each item in sorted order. T
    14·1 answer
  • Can anybody teach me how to make an app with flask and pygame together?​
    10·1 answer
  • Two technicians are discussing the intake air temperature (IAT) sensor. Technician A says that the computer uses the IAT sensor
    9·1 answer
  • If a machine uses LESS effort to overcome a given resistance force (if Fe is less than FR), it has an actual mechanical advantag
    13·1 answer
  • A flat-plate solar collector is 2 m long and 1 m wide and is inclined 60o to the horizontal. The cover plate is separated from t
    13·1 answer
  • Communication "works" to the degree that a wide variety of information is completely and thoroughly shared among the parties, an
    13·1 answer
  • You are a technical writer for Landson Toy Company. Landson has just designed a new, more durable swing set for 6- to 10-year-ol
    9·1 answer
  • 6. Question
    13·1 answer
  • Suppose you are asked to design an office building. Explain what type of drawing you would use and why.
    8·2 answers
  • Find the remaining trigonometric functions of 0 if
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!