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
You have just purchased a server with Windows Server 2016 Datacenter Edition installed. The server has 4 GB RAM, a 200 GB hard d
Elena L [17]

Answer:

a. Install more RAM

Explanation:

According to my research on information technology, I can say that based on the information provided within the question this server will not work for you purpose unless you install more RAM. This is because Hyper-V server's have a minimum requirement of 4gb, therefore if you want to run 2 servers you can divide all the resources you have since they are enough but not the RAM since you only have the bare minimum for one server. You need to add atleast 4 gb more of RAM.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

4 0
3 years ago
Suppose you want to delete an existing file from within word. What would you do?
Oksana_A [137]
Go in to ur files and find the file and delete it
5 0
3 years ago
What is resource Management in Wireless Communication ? Explain its Advantages?
Brut [27]

Answer:

Resource management is the system level transmission cellular networks and wireless communication.

Explanation:

Wireless communication is the process to continue to the address for faster response time,to the resource management.

Transmission is the provided by that more utilization and wireless resources available,and to discovered data.

Wireless communication system to demand the larger bandwidth and transmission using development to the system.

Wireless communication resources management the larger bandwidth and reliable transmission consumed all the system layer.

Resource management techniques tool are used in a preliminary concepts or mathematical tools,and average limited power battery.

Resource management are they necessary mathematical and fundamental tools are used in wireless communication.

Wireless communication in the provide that wireless industry in a wireless communication.

8 0
3 years ago
What feature is not included in most DTP programs?
IceJOKER [234]
Features included in most DTP programs would be kerning, master pages, and WYSIWYG. S video editing isn't included in most programs for DTP
5 0
3 years ago
#It helps in the proper function ing of computer hardware.
zalisa [80]
4- system software
2- application software
4- software package
1- assembler
2- antivirus program
3 0
3 years ago
Other questions:
  • Custom parameters 1, 2 and 3 provide the same end value for all keywords. true or false?
    14·1 answer
  • You have found statistics on the Internet that you would like to use in your speech.
    6·1 answer
  • What are the four stages a customer goes through when buying a product?
    7·2 answers
  • Code the function definition for aNonclassFunction, picking up co. aNonclassFunction has no return value.
    8·1 answer
  • 20 points for ez question lol
    9·2 answers
  • In the context of computer and network security, _____ means that a system must not allow the disclosing of information by anyon
    10·1 answer
  • Operands may be any of the following: (select all that apply) Group of answer choices constant or constant expression register n
    11·1 answer
  • What aspect should you consider before adding pictures to a document?
    6·1 answer
  • I need help 50 points and brainiest if you answer
    10·2 answers
  • c g given an array, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero eleme
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!