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:
import java.lang.Math;
import java.util.Scanner;
public class SensorThreshold {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
double targetValue;
double sensorReading;
targetValue = scnr.nextDouble();
sensorReading = scnr.nextDouble();
if (Math.abs(sensorReading - targetValue) < 0.001) {
System.out.println("Equal");
}
else {
System.out.println("Not equal");
}
}
}
Also in JavaScript:
- javascript var dump
- vue js documentation
- javascript filter array of objects
- mv multiple directories
- saveas angular 6
- Object destructuring
- vue truncate text
- react lifecycle
- js shortcut
- passport how to replace missing credential
- best react boilerplate 2019
- vue js vForm
- not selector jquery
- javascript remove last item
- uuid generator js
- clear the console while in strict mode
- manage favicon with express app
- download audio file javascript
- find the missing value in an integer array javascript
- if object is array javascript
- read data from url node js
- javascript get random integer in given range
- javascript closure function example
- react memo