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
ryzh [129]
2 years ago
13

Consider the following code segment, which is intended to simulate a random process. The code is intended to set the value of th

e variable event to exactly one of the values 1, 2, or 3, depending on the probability of an event occurring. The value of event should be set to 1 if the probability is 70 percent or less. The value of event should be set to 2 if the probability is greater than 70 percent but no more than 80 percent. The value of event should be set to 3 if the probability is greater than 80 percent. The variable randomNumber is used to simulate the probability of the event occurring.
int event = 0;
if (randomNumber <= 0.70)
{
event = 1;
}
if (randomNumber <= 0.80)
{
event = 2;
}
else
{
event = 3;
}
The code does not work as intended. Assume that the variable randomNumber has been properly declared and initialized. Which of the following initializations for randomNumber will demonstrate that the code segment will not work as intended?
A) randomNumber = 0.70;
B) randomNumber = 0.80;
C) randomNumber = 0.85;
D) randomNumber = 0.90;
E) randomNumber = 1.00;
Computers and Technology
1 answer:
lora16 [44]2 years ago
3 0

Answer:

A) randomNumber = 0.70;

Explanation:

The code works perfectly for all values of randomNumber given in the options except option (a)

This is so because:

The first condition

<em>if (randomNumber <= 0.70)  {  event = 1;  }</em>

It checks if randomNumber is less than or equal to 0.70. This is true, so event is set to 1.

However, the next condition after it will also be executed because it is a different conditional to be executed.

So, we have:

if (randomNumber <= 0.80)  {  event = 2;  }

This condition is also true, so event is set to 2.

From the question randomNumber is meant to be event 1. However, this is different from the result of executing the code.

Hence, (a) is true

You might be interested in
Your boss wants you to configure his laptop so that he can access the company network when he is on the road. You suggest a VPN
Rashid [163]

Answer:

All traffic that flows between the laptop and VPN server is encrypted.

Explanation:

A Virtual Private Network (VPN) is a "tunnel" connection between computers that performs just like a regular point-to-point network connection (that is, IP address to IP address).  It has the added feature that encryption is enabled so that no intermediate server (or computer or line monitor, etc.) can decode the information that is in the data portion of the packets.

5 0
3 years ago
You want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. to do so, you shoul
nikklg [1K]

If you want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. to do so, you should type chmod a <u>t  <subdir>.</u>

<h3>What is Subdir?</h3>

The Definition of the term subdirectory is known to be a kind of an organizational directory that can be seen on a computer.

It is known to be one that can be found inside another directory  such as a subfolder. It is seen as the file a person is looking for and it is one that needs to have an extension.

Therefore, if you want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. to do so, you should type chmod a <u>t  <subdir>.</u>

Learn more about directory from

brainly.com/question/14845522

#SPJ1

See full question below

You want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. To do so, you should type:

chmod a+_____ <subdir>

- s

- p

- b

- t

6 0
1 year ago
Select the correct answer.
Naddika [18.5K]

Answer:

E

Explanation:

4 0
3 years ago
A computer program that translates a program statement by statement into machine language is called a/an?
PtichkaEL [24]
Executor. IT executes the program.
6 0
3 years ago
Write an If...Then statement that assigns 0 to intX when intY is equal to 20
BigorU [14]

Answer:

wh,,what?

Explanation:

3 0
2 years ago
Read 2 more answers
Other questions:
  • Write a program that takes as input an arithmetic expression followed by a semicolon ";". The program outputs whether the expres
    11·1 answer
  • You want to know what directories in your account hold C files. You can use the command:______.
    9·1 answer
  • A technician is configuring a new SOHO multifunction wireless router at a customer’s location to provide network access to sever
    12·1 answer
  • At the beginning of a chapter in a book, the first letter often appears larger than the other text on the page. This
    15·1 answer
  • What is an avenue in a Karel world?
    6·2 answers
  • Read the scenario below, and then answer the question.
    13·1 answer
  • Is a collection of information stored under a single nam​
    6·2 answers
  • Which of the following describes a decision support system (DSS)?
    12·2 answers
  • tell us things u did as a kid but don't want to admit to it (best gets brainly 5 stasr and a thank you)
    13·2 answers
  • Carlos has become pretty efficient at using the Word Processor but he takes time to use the menu each time he saves, prints and
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!