# Program to Find The Maximum And Minimum of Any Five Integer Numbers

The program below is the answer to Deitel's Java How to Program (9th Edition) Chapter 2 Exercise 2.24.

Question: Write an application that reads five integers and determines and prints the largest and smallest integers in the group. Use only the programming techniques you learned in this chapter.

```/**
*
* @Author: Aghatise Osazuwa
* Website: www.cscprogrammingtutorials.com
*
* Exercise 2.24 - Largest And Smallest Integers
* This Program Determines The Largest And Smallest of Any Five Integer Numbers
*
*/

import java.util.Scanner;

public class Ex02_24 {
public static void main (String [] args) {

Scanner value = new Scanner (System.in);

int num1;
int num2;
int num3;
int num4;
int num5;
int largest;
int smallest;

System.out.print ("\nEnter Your First Number: ");
num1= value.nextInt();
System.out.print ("\nEnter Your Second Number: ");
num2= value.nextInt();
System.out.print ("\nEnter Your Third Number: ");
num3= value.nextInt();
System.out.print ("\nEnter Your Fourth Number: ");
num4= value.nextInt();
System.out.print ("\nEnter Your Fifth Number: ");
num5= value.nextInt();

largest = num1; // assume largest is the first number
if (num2 > largest)
largest = num2;
if (num3 > largest)
largest = num3;
if (num4 > largest)
largest = num4;
if (num5 > largest)
largest = num5;

smallest = num1; // assume smallest is the first number
if (num2 < smallest)
smallest = num2;
if (num3 < smallest)
smallest = num3;
if (num4 < smallest)
smallest = num4;
if (num5 < smallest)
smallest = num5;

System.out.printf ("\nLargest = %d\nSmallest = %d\n", largest, smallest);

}
}
```