/** * IfTest.java * * @author Jeff Ondich * January 4, 2005 * * This program demonstrates a simple if-else-if-else construction, * and also tests the integer division and modulus/remainder * operators (/ and %, respectively). */ import java.util.*; public class IfTest { public static void main( String[] args ) { Scanner in = new Scanner( System.in ); System.out.print( "Number? " ); int number = in.nextInt(); if( number > 5 ) { System.out.println( "Wow, what a big number!" ); } else if( number == 5 ) { System.out.println( "That number is just right." ); } else { System.out.println( "Gosh, what an adorably small number!" ); } System.out.println( "Your number was " + number ); // Testing the % operator. int quotient = number / 100; int remainder = number % 100; System.out.println( "Quotient (divided by 100): " + quotient ); System.out.println( "Remainder (divided by 100): " + remainder ); } }