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

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!