All pastes #2063965 Raw Edit

Miscellany

public text v1 · immutable
#2063965 ·published 2011-05-19 00:18 UTC
rendered paste body
package question1a;

import java.util.Scanner;

public class Question1a {

    public static void main(String[] args) {
        
        //Declare integer varibles
        int a, b, c, d, e, max, min;                        
        
        //Initialize input
        Scanner keyboard = new Scanner(System.in);

        System.out.println("Enter five integer numbers");
        a = keyboard.nextInt();
        b = keyboard.nextInt();
        c = keyboard.nextInt();
        d = keyboard.nextInt();
        e = keyboard.nextInt();
        
        //Inititlize max and min as base value a in order to compare numbers
        max = min = a;

        //Compare inputted integers to base value a
        if (b < min) {
            min = b;
        }
        if (b > max) {
            max = b;
        }

        if (c < min) {
            min = c;
        }
        if (c > max) {
            max = c;
        }

        if (d < min) {
            min = d;
        }
        if (d > max) {
            max = d;
        }

        if (e < min) {
            min = e;
        }
        if (e > max) {
            max = e;
        }
        
        //Print out max and min to console
        System.out.println("The minimum is " + min + " and the maximum is " + max);
    }
}