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
Types of motherboard​
Arada [10]

Answer:

Types of Motherboard

Explanation:

Motherboards are present in Desktop, Laptop, Tablet, and Smartphone and the components and functionalities are the same. But the size of the components and the way they are accommodated on the board varies due to space availability. In desktops, most of the components are fitted inside the sockets provided on the board and it is easy to replace each of them separately, whereas in Laptops/Smartphones some components are soldered on the board, hence it is difficult to replace/upgrade.

Though different motherboards have varying capabilities, limitations, features, Physical size/shapes (form factor), they are identified/grouped/categorized mostly by their form factors. Each manufacturer has come out with its form factor to suit the design of computers. Motherboard manufactured to suit IBM and its compatible computers fit into other case sizes as well. Motherboards built using ATX form factors were used in most of the computers manufactured in 2005 including IBM and Apple.

6 0
3 years ago
Which of the following is the best definition of metatheatre?
grandymaker [24]

Answer:"Metatheatre" is a convenient name for the quality or force in a play which challenges theatre's claim to be simply realistic -- to be nothing but a mirror in which we view the actions and sufferings of characters like ourselves, suspending our disbelief in their reality.

Explanation:

7 0
3 years ago
The major objective of this lab is to practice class and object-oriented programming (OOP), and separate files: 1. We will reuse
vovangra [49]

Answer:

Implementation of resistor.cpp

#include "resistor.h"

Ohms::Ohm()

{

// default constructor

voltage=0;

}

Ohms::Ohm( double x) // parameterised constructor

{

voltage = x; // voltage x set to the supply voltage in the private data field called voltage

}

Ohms:: setVoltage(double a)

{

voltage = a;// to set supply voltage in private data field called voltage

}

Ohms::setOneResistance( String s, double p)

{

cin>>p; //enter the resistance value

if(p<=0) // if resistance is less than or equals to 0

return false

else // if re

cin.getline(s);

}

Ohms::getVoltage()

{

return voltage; //return voltage of ckt

}

Ohms::getCurrent()

{

return current; //return current of ckt

}

Ohms:: getNode()

{

return resistors; //return resistors of ckt

}

Ohms::sumResist()

{

double tot_resist = accumulate(resistors.begin(),resistors.end(),0); //std::accumulate function for calculating sum //of vectors and following are the starting and ending points

return tot_resist;

}

Ohms::calcCurrent()

{

if(current <=0) // if current is less than or equal to 0

return false;

else   // if current is greater than 0

return true;

}

Ohms:: calcVoltageAcross()

{

if(voltage<=0) // if voltage is less than or equal to 0

return false;

else //if voltage greater than 0

return true;

}

Explanation:

in the case of main.cpp its simple just make a class object and remember to include resistors.cpp with it for which the second last picture describes the process precisely. (Hint: Use theunit test case functions in the main.cpp).

As you can see node is a structure consisting of member variables, followed by a class Ohms representing a DC circuit.

By looking at these pictures, it is needed to implement the main.cpp and resistor.cpp files. The user defined header file resistor.h already consists of all contents of Class Ohm, struct node. You don't need to modify it in anyway in such case.

8 0
3 years ago
Windows organises information on computer using a
lana66690 [7]
B folder
hope i helped
8 0
3 years ago
Read 2 more answers
6. While using the HTS, ________________ will help maintain a safe driving environment despite high speeds and a large number of
levacccp [35]
It would be C, because the other ones would be breaking the law. using the horn over and over again is annoying. cell phone is distracted driving. driving slow than the speeding limit is against the law. so the only good choice is C because following the laws will not get you in trouble.
7 0
3 years ago
Other questions:
  • Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). O
    5·1 answer
  • When considering server consolidation, plan on running ___________ vCPUs per core.a. 1 to 2b. 3 to 4c. 4 to 6d. 6 to 8
    7·1 answer
  • . Which game was the most popular free download in Apple®’s app store by January 2014, despite poor reviews and plagiarism accus
    14·2 answers
  • A set of instructions to increase a programmer’s pay rate by 10 percent is hidden inside an authorized program. It changes and u
    6·1 answer
  • Jackson builders is constructing new homes in the Parkway subdivision.The company needs the logic for an application that ncalls
    13·1 answer
  • Assume user_name equals "Tom" and user_age equals 22. What is printed on the console when the following statement is executed? c
    14·1 answer
  • Consider the following code: String word [] = {"algorithm", "boolean", "char", "double"}; for ( int i =0; i &lt; word.length/2;
    11·2 answers
  • HELP ASAP
    7·1 answer
  • In a multiple-column record of a data file, ______ represent different variables and _______ represent different cases
    15·1 answer
  • An Accenture healthcare client is interested in implementing an Artificial Intelligence (AI) solution to improve patient care, b
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!