Question: Write an expression that will cause the following code to print less than 18 if the value of userAge is less than 18. import java.util.Scanner;
Write an expression that will cause the following code to print "less than 18" if the value of userAge is less than 18.
import java.util.Scanner;
public class AgeChecker { public static void main (String [] args) { int userAge;
Scanner scnr = new Scanner(System.in); userAge = scnr.nextInt(); // Program will be tested with values: 16, 17, 18, 19.
if (/* Your solution goes here */) { System.out.println("less than 18"); } else { System.out.println("18 or more"); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
