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
4. Explain the term prejudice. What is an example of prejudice as it relates to parenting?
lara [203]
An unfavorable opinion or feeling formed beforehand or without knowledge, thought, or reason.
2.
any preconceived opinion or feeling, either favorable or unfavorable.
3.
unreasonable feelings, opinions, or attitudes, especially of a hostile nature, regarding an ethnic, racial, social, or religious group.
4.
such attitudes considered collectively:
The war against prejudice is never-ending.
5.
damage or injury; detriment:
a law that operated to the prejudice of the majority.
7 0
3 years ago
A user is troubleshooting a mobile device app that is displaying errors and has contacted the app manufacturer’s technical suppo
dlinn [17]

Answer:

The answer is "The user uses the method for retrieval, which is dependent on the specific app or devices on the operating system".

Explanation:

For retrieving the requested information of the form, with the user device, he uses the retrieval method, which is based upon the specific application or system operating system.

  • In this, the user can resolve the mobile phone application but also show the errors which have been committed to the assistance team of the application manufacturer.
  • Its repair technician requires detailed system data on the way the software responds and also what triggers the mistakes.
4 0
3 years ago
Which of the following behaviors is considered ethical?
kolezko [41]

Answer:

answer is c. using a limited access public computer to watch movies

7 0
2 years ago
Read 2 more answers
Select the correct answer. Richard wants to use a technology that allows the automation of manufacturing cars in his factory. Wh
Gemiola [76]

CAM C. rapid prototyping is the correct option for Richard wants to use a technology that allows the automation of manufacturing cars in his factory.

<h3>What is prototyping?</h3>

Prototyping is an iterative process in which design teams translate abstract ideas into tangible forms, which might range from paper to digital.

To capture design concepts and test them on people, teams create prototypes of varied degrees of quality. one can modify and validate designs with prototypes.

Thus, option B is correct.

For more details about prototyping, click here

brainly.com/question/24231598

#SPJ1

6 0
1 year ago
Read 2 more answers
The political spectrum spans from Communism on the extreme left to __________ on the extreme right. /8178757/1f6bdbf3?utm_source
Delvig [45]
If the options are: <span><span><span>A.Socialism, </span><span>B.Liberalism, </span><span>C.Anarchism, </span>D.Conservatism, then the answer is D. Conservatism. I can see that some people have previously answered Anarchism. But it can't be the right answer because anarchism does not advocate either leftist or rightist politics - it advocates stateless politics. On the other hand, both left-wing and right-wing politics operate within the conventional field of states and governments. Now, communism is the extreme leftist position of egalitarianism, that is social equality, without private property. On the other hand, conservatism advocates social hierarchies and inequality as a natural order of society. Liberalism isn't the answer either because it isn't a rightist political option.</span></span>
6 0
3 years ago
Read 2 more answers
Other questions:
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • What is needed to create a good problem statement?
    10·1 answer
  • If you decide to get married, a trade-off would be that you have to give up being single.
    12·2 answers
  • Which is a benefit of using the paste link option?
    15·2 answers
  • What was your learning target for today
    9·2 answers
  • It took her 9 more months but Marina has managed to save the full $725 plus more to cover fees to pay off the pay-day loan compa
    9·1 answer
  • A corporation is looking to receive approval from its shareholders. The corporation needs to communicate financial information a
    11·1 answer
  • 25 points
    8·2 answers
  • A(n) ________ attempts to slow down or stop a computer system or network by sending repetitive requests for information.
    6·1 answer
  • The layer of the ISO/OSI responsible for source to destination delivery.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!