import java.util.Scanner; public class LogicOperators { public static void main(String[] args) { int counter = 5; // arbitrary choice of number int number = promptInt("What is the counter value"); if (10 < number && number < 20) { counter = counter + 1; System.out.println("updating counter to " + counter); } int age = promptInt("What is your age"); if (age < 10 || 60 < age) { System.out.println("You get a discount"); } boolean emp = promptBoolean("Are you a NosCorp Employee"); if (age > 18 && !emp){ System.out.println("Coupon Accepted"); } else { System.out.println("Either underage or employee. Ineligible for coupon"); } } // utility for reading in integer input public static int promptInt(String promptText) { System.out.print(promptText + " "); Scanner scan = new Scanner(System.in); int response = scan.nextInt(); return response; } // utility for reading in double input public static double promptDouble(String promptText) { System.out.print(promptText + " "); Scanner scan = new Scanner(System.in); double response = scan.nextDouble(); return response; } // utility for reading in String input public static String promptString(String promptText) { System.out.print(promptText + " "); Scanner scan = new Scanner(System.in); String response = scan.nextLine(); return response; } // utility for reading in boolean input public static boolean promptBoolean(String promptText) { System.out.print(promptText + " (y/n) "); Scanner scan = new Scanner(System.in); String response = scan.nextLine(); return response.equalsIgnoreCase("y"); } }