> Need help in Java Programming using JCreator PRO?

Need help in Java Programming using JCreator PRO?

Posted at: 2014-12-18 
import java.util.Scanner;

public class Program {

public static void main(String[] args) {

int max = Integer.MIN_VALUE;

int min = Integer.MAX_VALUE;

for (int i = 0; i < 5; i++) {

System.out.println("Enter an integer? ");

Scanner keyboard = new Scanner(System.in);

int input = keyboard.nextInt();

max = Math.max(max, input);

min = Math.min(min, input);

}

System.out.format("max=%d, min=%d", max, min);

}

}

My Instructor asked me to make a program that will ask for 5 Integer numbers to be input and the program will display the maximum and minimum among those 5 integer.

I already tried to make one but when I'm in else if statement I don't know how or what to write. 3 Integers would be easy but 5 is so hard I don't know what or how to arrange or what there process might be. please help

if (num1 > num2 && num2 > num3 && num3 > num4 && num4 > num5)

{

System.out.print("Maximum is " + num1);

System.out.print("Minimum is " + num5);

}

else if (num1 < num2 && num2 < num3 && num3 < num4 && num4 < num5)

{

System.out.print("Maximum is " + num5);

System.out.print("Minimum is " + num1);

}

else if (num1 < num2 && num2 > num3 && num3 < num4 && num4 < num5)

{

System.out.print("Maximum is " + num2);

System.out.print("Minimum is " + num5);

}

I don't know if this is right please help me