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
(c) As Engineering and Computing students, you must be familiar, with the respective professional bodies, as well as, Rules of P
guajiro [1.7K]

The professional ethics for computer engineers are:

  • They will Contribute to society and to human well-being.
  • They will  Avoid harm.
  • Be honest and trustworthy.
  • They will be fair and take action that do to discriminate others.

<h3>What are the Characteristics of Code of Ethics?</h3>

The code of ethics are known to be a kind of a universal moral values, that is one that state that what a person expect of any given employee such as been trustworthy, respectful, responsible, and others.

Note that Rules of Practice, Professional Obligations and Codes of Ethics. are known to be put in place to avoid issues that may lead to conflict.

Therefore, i believe that  As Engineering and Computing students, the respective professional bodies, Rules of Practice, Professional Obligations and Codes of Ethics are good and acts as a check and balance to us.

Therefore, The professional ethics for computer engineers are:

  • They will Contribute to society and to human well-being.
  • They will  Avoid harm.
  • Be honest and trustworthy.
  • They will be fair and take action that do to discriminate others.

Learn more about Engineering rules from

brainly.com/question/17169621

#SPJ1

4 0
1 year ago
A counter-flow double-piped heat exchange is to heat water from 20oC to 80oC at a rate of 1.2 kg/s. The heating is to be accompl
lawyer [7]

Answer:

110 m or 11,000 cm

Explanation:

  • let mass flow rate for cold and hot fluid = M<em>c</em> and M<em>h</em> respectively
  • let specific heat for cold and hot fluid = C<em>pc</em> and C<em>ph </em>respectively
  • let heat capacity rate for cold and hot fluid = C<em>c</em> and C<em>h </em>respectively

M<em>c</em> = 1.2 kg/s and M<em>h = </em>2 kg/s

C<em>pc</em> = 4.18 kj/kg °c and C<em>ph</em> = 4.31 kj/kg °c

<u>Using effectiveness-NUT method</u>

  1. <em>First, we need to determine heat capacity rate for cold and hot fluid, and determine the dimensionless heat capacity rate</em>

C<em>c</em> = M<em>c</em> × C<em>pc</em> = 1.2 kg/s  × 4.18 kj/kg °c = 5.016 kW/°c

C<em>h = </em>M<em>h</em> × C<em>ph </em>= 2 kg/s  × 4.31 kj/kg °c = 8.62 kW/°c

From the result above cold fluid heat capacity rate is smaller

Dimensionless heat capacity rate, C = minimum capacity/maximum capacity

C= C<em>min</em>/C<em>max</em>

C = 5.016/8.62 = 0.582

          .<em>2 Second, we determine the maximum heat transfer rate, Qmax</em>

Q<em>max</em> = C<em>min </em>(Inlet Temp. of hot fluid - Inlet Temp. of cold fluid)

Q<em>max</em> = (5.016 kW/°c)(160 - 20) °c

Q<em>max</em> = (5.016 kW/°c)(140) °c = 702.24 kW

          .<em>3 Third, we determine the actual heat transfer rate, Q</em>

Q = C<em>min (</em>outlet Temp. of cold fluid - inlet Temp. of cold fluid)

Q = (5.016 kW/°c)(80 - 20) °c

Q<em>max</em> = (5.016 kW/°c)(60) °c = 303.66 kW

            .<em>4 Fourth, we determine Effectiveness of the heat exchanger, </em>ε

ε<em> </em>= Q/Qmax

ε <em>= </em>303.66 kW/702.24 kW

ε = 0.432

           .<em>5 Fifth, using appropriate  effective relation for double pipe counter flow to determine NTU for the heat exchanger</em>

NTU = \\ \frac{1}{C-1} ln(\frac{ε-1}{εc -1} )

NTU = \frac{1}{0.582-1} ln(\frac{0.432 -1}{0.432 X 0.582   -1} )

NTU = 0.661

          <em>.6 sixth, we determine Heat Exchanger surface area, As</em>

From the question, the overall heat transfer coefficient U = 640 W/m²

As = \frac{NTU C{min} }{U}

As = \frac{0.661 x 5016 W. °c }{640 W/m²}

As = 5.18 m²

            <em>.7 Finally, we determine the length of the heat exchanger, L</em>

L = \frac{As}{\pi D}

L = \frac{5.18 m² }{\pi (0.015 m)}

L= 109.91 m

L ≅ 110 m = 11,000 cm

3 0
3 years ago
Differnence between boat and ship​
Blababa [14]

Answer:

a ship is a large vessel intended for oceangoing or at least deep-water transport, and a boat is anything else." Basically, a ship can carry a boat, but a boat cannot carry a ship

5 0
3 years ago
Read 2 more answers
Explain all the characteristics of computer<br>​
Sedaia [141]
They are as follows-

Speed
Accuracy
Storage
Versatility
Diligence
Automation
Reliability
Power of Remembering

Let us understand each characteristic in brief:-

Speed – Speed of a computer means the time it takes to complete any given task. The computer works at a very lightning speed. For example, a computer takes a second to calculate 3 million calculations rather than a human which takes years. Hence nowadays the speed of the computer is measured in terms of microseconds, Nanoseconds, and even in Pico seconds instead of seconds or milliseconds.


Accuracy – The computers are programmed and designed in such a manner that their results are almost 100% accurate. It performs all the tasks with the same accuracy. There are very few chances of uncertainty in results and even though an error occurs, it can happen either due to wrong input data or unreliable programs by a programmer. Such errors are referred to as Garbage In Garbage Out (GIGO) which means, if you provide wrong instructions to the computer then you get wrong results.


Versatility – Along with being accurate and diligent a computer is also a versatile device. It can perform several types of tasks at a time if they are reduced to a certain set of logical steps. A computer can be used for many purposes at different places such as booking air and rail tickets, weather forecasting, listening to music, and playing games. Also at a time, one can pay his utility bills and can make a monthly budget too. It can prepare documents, data sheets and also can make models of houses, dams, etc.
Diligence – The ability of a computer to perform tasks without getting tired is known as diligence. Computers are highly reliable, they do not get fed up, exhausted, or lack concentration. They can work for hours and hours unlike humans and can give accurate or error-free results. For example, humans will start feeling tired after 2 -3 hours and will lack concentration whereas a computer will keep on working until the results are achieved.
Automation – Automation means working automatically. A computer can work on its own without the intervention of the person using it. Programs can be made for the computer to perform the task and based on the sequence it executes the tasks and gives accurate results. In case an error occurs, it gives error messages too and registers the logs.
Reliability – High reliability of a computer depends on low failure rate and easy maintenance. The results given out by the computer are reliable as the accuracy is almost 100%.
Power of Remembering – The computer has the power of storing data or information for several years. It cannot lose the data on its own. A person can retrieve the data whenever required and the data remains the same after a number of years also. It gives the freedom to the user to decide on how much data to store and how much to remove.
5 0
3 years ago
**Please Help, ASAP**
Novay_Z [31]

Explanation:

We need to rearrange the following formula for the values given in parenthesis.

(1) x+xy = y, (x)

taking x common in LHS,

x(1+y)=y

x=\dfrac{y}{1+y}

(2) x+y = xy, (x)

Subrtacting both sides by xy.

x+y-xy = xy-xy

x+y-xy = 0

x-xy=-y

x(1-y)=-y

x=\dfrac{-y}{1-y}

(3) x = y+xy, (x)

Subrating both sides by xy

x-xy = y+xy-xy

x(1-y)=y

x=\dfrac{y}{1-y}

(4) E = (1/2)mv^2-(1/2)mu^2, (u)

Subtracting both sides by (1/2)mv^2

E-(1/2)mv^2 = (1/2)mv^2-(1/2)mu^2-(1/2)mv^2

E-(1/2)mv^2 =-(1/2)mu^2

So,

2(E-\dfrac{1}{2}mv^2)=-mu^2\\\\u^2=\dfrac{-2}{m}(E-\dfrac{1}{2}mv^2)\\\\u=\sqrt{\dfrac{-2}{m}(E-\dfrac{1}{2}mv^2)}\\\\u=\sqrt{\dfrac{2}{m}(\dfrac{1}{2}mv^2-E)}

(5) (x^2/a^2)-(y^2/b^2) = 1, (y)

\dfrac{x^2}{a^2}-1=\dfrac{y^2}{b^2}\\\\y^2=b^2(\dfrac{x^2}{a^2}-1)\\\\y=b\sqrt{\dfrac{x^2}{a^2}-1}

(6) ay^2 = x^3, (y)

y^2=\dfrac{x^3}{a}\\\\y=\sqrt{\dfrac{x^3}{a}}

Hence, this is the required solution.

3 0
3 years ago
Other questions:
  • Let A→=(150iˆ+270jˆ) mm , B→=(300iˆ−450jˆ) mm , and C→=(−100iˆ−250jˆ) mm . Find scalars r and s, if possible, such that R→=rA→+s
    13·1 answer
  • A drainage ditch alongside a highway with a 3% grade has a rectangular cross-section of depth 4 ft and width 8 ft, and is fully
    12·1 answer
  • Which type of load is not resisted by a pinned joint? A) Moment B) Shear C) Axial D) Compression
    7·1 answer
  • What is the ratio between driver gear A with 60 teeth and driven gear B with 180 teeth?
    12·1 answer
  • Which Finance jobs can someone pursue with only a high school diploma? Check all that apply.
    10·2 answers
  • 96/64 reduced to its lowest term
    12·1 answer
  • Stress that acts in the plane of a cut section, rather than at right angles to the section is called:_______
    6·1 answer
  • Identify the Levels of Biological Organization below. Copy and answer each statement. Write
    7·1 answer
  • Could you please answer this question clearly?
    11·1 answer
  • A particle moving on a straight line has acceleration a = 5-3t, and its velocity is 7 at time t = 2. If s(t) is the distance fro
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!