subject

Consider the following code segment, which is intended to simulate a random process. The code is intended to set the value of the 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;

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 24.06.2019 10:00
3. what do the terms multipotentialite, polymath, or scanner mean?
Answers: 2
question
Computers and Technology, 24.06.2019 21:40
Clunker motors inc. is recalling all vehicles in its extravagant line from model years 1999—2002 as well as all vehicles in its guzzler line from model years 2004—2007. a boolean variable named recalled has been declared. given a variable modelyear and a string modelname, write a statement that assigns true to recalled if the values of modelyear and modelname match the recall details and assigns false otherwise.
Answers: 2
question
Computers and Technology, 24.06.2019 22:10
In command prompt, whats a command that will list only .ini files in c: \windows\system32 directory?
Answers: 1
You know the right answer?
Consider the following code segment, which is intended to simulate a random process. The code is int...
Questions
question
Mathematics, 19.03.2021 22:40
question
Arts, 19.03.2021 22:40
question
Mathematics, 19.03.2021 22:40
question
Mathematics, 19.03.2021 22:40
Questions on the website: 13722360