Try to use arrays (read about it) for such a problems like this, when you need to store more than one input of the same type data.
import java.util.Scanner;
public class Array {
public static void main(
String[] args) {
Scanner in = new Scanner(System.in);
// create an array of 3 elements
int[] array = new int[3];
// ask user input
System.out.println("Enter three numbers followed by space: ");
// store user's inputs in an array
for (int i = 0; i < 3; i++) {
array[i] = in.nextInt();
}
/*
* Over here, try to think and figure it out, how to sort these array elements.
* Each array element can be accessed by indexes.
* For ex. array[0] - 1st element in an array
* array [1] - 2nd
* array [2] - third element in array and it is your last element.
* As they start from index 0, 1, 2 << 3 (...new int[3])
*/
// print elements of array
for (int i = 0; i < 3; i++) {
System.out.println(array[i]);
}
in.close();
}
}