import java.util.Scanner; public class CompoundConditional { public static void main(String[] args) { int num, months, miles; Scanner sc = new Scanner(System.in); final int LOWER_LIMIT = 35; final int UPPER_LIMIT = 70; System.out.print( "Enter a number between " + LOWER_LIMIT + " and " + UPPER_LIMIT + ": "); num = sc.nextInt(); if ((num > LOWER_LIMIT) && (num < UPPER_LIMIT)) { System.out.println("Thank you."); } else { System.out.println( "That's not between " + LOWER_LIMIT + " and " + UPPER_LIMIT + "."); } /* Even though these constant values are only used once each * in this program, we still make them named constants for * good style and future flexibility and readability. */ final int MONTH_BOUNDARY = 3; final int MILES_BOUNDARY = 3000; System.out.print("How many months since your last oil change? "); months = sc.nextInt(); System.out.print("How many miles since your last oil change? "); miles = sc.nextInt(); if ((months >= MONTH_BOUNDARY) || (miles > MILES_BOUNDARY)) { System.out.println("Get an oil change!"); } else { System.out.println("Keep on driving..."); } } } //Copyright 2010-2012 : Evan Golub