Question: if the input is 3 . 9 X 2 . 5 what is the output? import java.util.Scanner; import java.util.InputMismatchException; public class VoltageLevelsExceptHandling { public static

if the input is 3.9 X 2.5 what is the output? import java.util.Scanner;
import java.util.InputMismatchException;
public class VoltageLevelsExceptHandling {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
double voltageLevel;
while (scnr.hasNext()){
try {
voltageLevel = scnr.nextDouble();
if (voltageLevel >=3.6){
System.out.println("on");
}
else if (voltageLevel >=0.0 && voltageLevel <=1){
System.out.println("off");
}
else {
System.out.println("?");
}
}
catch (InputMismatchException excpt){
System.out.println("Error getting input");
scnr.next();
}
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!