Define the method inspectVals() with a Scanner parameter that reads integers from input until 0 is read. The method returns true if none of the integers read before 0 are 1000. Otherwise, the method returns false. Ex: If the input is 1005 1001 997 0, then the output is: 1000 not present import java.util.Scanner; public class ValueInspector { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); boolean valueNotPresent; valueNotPresent = inspectVals(scnr); if (valueNotPresent) { System.out.println("1000 not present"); } else { System.out.println("Found one or more 1000s"); } } }
Define the method inspectVals() with a Scanner parameter that reads integers from input until 0 is read. The method returns true if none of the integers read before 0 are 1000. Otherwise, the method returns false.
Ex: If the input is 1005 1001 997 0, then the output is:
1000 not present
import java.util.Scanner;
public class ValueInspector {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
boolean valueNotPresent;
valueNotPresent = inspectVals(scnr);
if (valueNotPresent) {
System.out.println("1000 not present");
}
else {
System.out.println("Found one or more 1000s");
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images