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]
3 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]3 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
A binary floating-poi Select 3 true statements about Python primitive types.
IRISSAK [1]

The true statements about Python primitive types.

  • 32-bit integer type (a.k.a. int32) can represent integer value from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)
  • A binary floating-point method is used to represent fractions in binary numbers.
  • The decimal number 0.1 cannot be expressed without error in binary floating-point format.

<h3>What are  Python primitive types?</h3>

The  Python primitive types is known to be made up of four primitive data types which are:

  • Integer.
  • Float.
  • String.
  • Boolean.

Note that The true statements about Python primitive types.

  • 32-bit integer type (a.k.a. int32) can represent integer value from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)
  • A binary floating-point method is used to represent fractions in binary numbers.
  • The decimal number 0.1 cannot be expressed without error in binary floating-point format.

Learn more about Python from

brainly.com/question/26497128

#SPJ1

7 0
2 years ago
In large organizations, there is a formal business function that includes developing an information policy, planning for data, o
Shkiper50 [21]

Answer:

Data administration.

Explanation:

Data management is a type of infrastructure service that avails businesses (companies) the ability to store and manage corporate data while providing capabilities for analyzing these data.

A database management system (DBMS) can be defined as a collection of software applications that typically enables computer users to effectively and efficiently create, store, modify, retrieve, centralize and manage data or informations in a database. Thus, it allows computer users to efficiently retrieve and manage their data with an appropriate level of security.

Generally, a database management system (DBMS) acts as an intermediary between the physical data files stored on a computer system and any software application or program.

Hence, a database management system (DBMS) is a system that enables an organization or business firm to centralize data, manage the data efficiently while providing authorized users a significant level of access to the stored data.

Data administration is a strategic process that is typically responsible for establishing information policy, data planning, data dictionary development, and monitoring data usage in the firm.

5 0
3 years ago
Which of the following was the name of the first generation of cell phone networks?
coldgirl [10]

Answer:

1G

Explanation:

1 'G' as in first generation.

Hope this helped. :)

3 0
3 years ago
Billy needs to type a bibliography/reference page for the report that he just typed. Which paragraph format should he use?
Olin [163]
He should use a MLA format

3 0
3 years ago
You're in the process of downloading some email messages when your antivirus software displays an alert. you assume the software
Y_Kistochka [10]
Please provide additional information in order to provide an answer to your question.
7 0
3 years ago
Other questions:
  • As referenced in this Canvas guide (Links to an external site.), Canvas is best viewed at a minimum of 800x600 pixels, which is
    5·1 answer
  • Which equation is correct regarding the measure of ∠MNP? m∠MNP = One-half(x – y) m∠MNP = One-half(x + y) m∠MNP = One-half(z + y)
    15·2 answers
  • A Chief Information Security Officer (CISO) needs to establish a KRI for a particular system. The system holds archives of contr
    13·1 answer
  • Please answer fast - screenshot included.
    5·1 answer
  • Dimensional arrays can be created using loops. 2 dimensional arrays can be created using:
    10·1 answer
  • Both the original location and destination must be visible in file explorer when you
    11·1 answer
  • Withdrawal from a conflict is best used when ______.
    6·2 answers
  • The Internet was first used by which of the following institutions?
    7·1 answer
  • The process of bringing data or a file from one program to another is called
    5·2 answers
  • Bộ mã I mã hóa được nhiêu kí tự
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!