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
kow [346]
3 years ago
15

Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targe

tValue. Otherwise, print "Not equal".
Computers and Technology
2 answers:
Likurg_2 [28]3 years ago
3 0

Answer:

The program to this question as follows:

Program:

targetValue = 0.3333 #defining variable targetValue and assign value

sensorReading = 0.0 #defining variable sensorReading and assign value

sensorReading = 1.0/3.0 #calculate value in sensorReading variable

Val=sensorReading - targetValue

#calculate the difference and store in Val variable

if (Val < 0.0001): #use of if block to check condition

  print ("Equal")  #print value

else:  #else block

  print ("Not equal") #print value

Output:

Equal

Explanation:

In the above Python program code, there are two variables "targetValue and sensorReading" is defined, in which targetValue store a value, that is "0.3333", and sensorReading holds a value, that is "0.0".

  • In the next step, the "Val" variable is defined, that calculate the difference between both variable, that conditional statement is used.
  • In if block, if the value is less then "0.0001", it will print value "Equal", otherwise, it will go to the else block, that will print "Not equal".
Anna11 [10]3 years ago
3 0

Full Question

Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targetValue. Otherwise, print "Not equal". Ex: If targetValue is 0.3333 and sensorReading is (1.0/3.0), output is: Equal

#include <iostream>

#include <cmath>

using namespace std;

int main() {

double targetValue;

double sensorReading;

cin >> targetValue;

cin >> sensorReading;

if (/* Your solution goes here */) {

cout << "Equal" << endl;

} else {

cout << "Not equal" << endl;

} return 0;

}

Answer:

if (abs(targetValue - sensorReading) <= 0.0001)

Explanation:

Replace

if (/* Your solution goes here */) {

With

if (abs(targetValue - sensorReading) <= 0.0001)

Two values are considered to be close enough if the difference between the values is 0.0001

Splitting the codes into bits;

abs

targetValue - sensorReading

<=

0.0001

The keyword abs is to return the absolute value of the expression in bracket.

This is needed because the expression in the bracket is expected to return a positive value.

To do this the absolute keyword is required.

targetValue - sensorReading returns the difference between the variables

<= compares if the difference falls within range that should be considered to be close enough

0.0001 is the expected range

You might be interested in
A) the Operating system is said to provide security. Explain what this means and give an example of a security feature.
Rzqust [24]

It means that thw operating system is up to date with all the lastest protection systems like an anti virus. An example is that the operating system has a built in ransomware protection system ib place.

Hope this help please give the brainliest award

3 0
3 years ago
Complete the function ConvertToDecadesAndYears to convert totalYears to decades and years. Return decades and years using the Ti
Sergeeva-Olga [200]

Answer:

It is a C++ program. The complete function   ConvertToDecadesAndYears which takes totalYears as parameter and convert totalYears to decades and years is provided in the attached document.

Explanation:

The explanation is provided in the attached document.

The screenshot of the complete code along with its output is attached.

6 0
3 years ago
The (blank) option will help determine the overall look of her presentation.
Valentin [98]

The slide layout option will help determine the overall look of her presentation.

<h3>Which option in a presentation program is vital?</h3>

Slide layouts is known to be a function that is made of  all the tools in regards to formatting, positioning, and others used in a slide and it is one that have all of the content that is seen on a slide.

Hence, The slide layout option will help determine the overall look of her presentation.

Learn more about presentation from

brainly.com/question/2189162

#SPJ1

7 0
2 years ago
Alfred, a software programmer at Gamma Inc., develops a program that spreads Trojan viruses to the organization’s network. When
Rasek [7]

Answer: (A) legal and ethical

Explanation:

 In the above given scenario, the liam's behaviors is consider as legal and ethical. The organization ethics is the morals of an association, and it is the means by which an association reacts to an inner or outside upgrade. Hierarchical morals is associated with the authoritative culture.

The ethical standard are basically depend on the human standards of good and bad and lawful guidelines depend on composed law, while moral norms depend on human rights and wrongs.

In the organization, the ethical and legal value are basically expressed by each employee as it is the regulatory law which is developed by the government for the particular organization to maintain the discipline.

3 0
4 years ago
John just bought a used iPad from a friend who had lost the charging cable. John notices that the cable is like the charging cab
Andre45 [30]
Micro usb,with a ios charging cable
8 0
3 years ago
Read 2 more answers
Other questions:
  • Annabeth has been using a public cloud to store and access her documents. Which drawback of a public cloud should she be aware o
    11·1 answer
  • In one to three sentences describe one reason you would import data into a datebase
    13·1 answer
  • The Outline tab and the Slides tab can be open at the same time.
    7·1 answer
  • Which of the following actions would not reduce software piracy? reducing the cost of software. offering downloads of software.
    12·2 answers
  • Any action that causes harm to your computer is called a
    15·1 answer
  • Cycle for science and technology<br>​
    14·1 answer
  • Which of the statements below are true? Which are false?
    14·1 answer
  • Identify the parts of it, Give at least three web browser that you usually used to visit a website.​
    10·1 answer
  • Who likes my meme? :)
    9·2 answers
  • What does the x mean in .docx
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!