I am stuck on a homework problem. I think I am on the right track but am getting stuck on the if/else statement. I could be totally wrong though.
Here is my assignment: Write a program that reads three integer inputs into variables. Display the input values in both the ordered entered and in sorted order. This program should sort the numbers so that value1 <= value2 <= value3.
I have only been learning Java for a couple weeks, any help would be appreciated. Hoping to make this a career one day.
Here is the code:
import java.util.Scanner;
public class OrderVariable {
public static void main (String [] args) {
Scanner input = new Scanner (System.in);
System.out.prntln("Enter first variable");
int VariableOne = input.nextInt();
System.out.prntln("Enter second variable");
int VariableTwo = input.nextInt();
System.out.prntln("Enter third variable");
int VariableThree = input.nextInt();
if (VariableOne > VariableTwo && VariableOne > VariableThree){
int Biggest = VariableOne;
else if (VariableTwo > VariableOne && VariableTwo > VariableThree);
int Biggest = VariableTwo;
} else (VariableThree > VariableOne && VariableThree > VariableTwo);
int Biggest = VariableThree;
if (VariableOne < VariableTwo && VariableOne < VariableThree){
int Smallest = VariableOne;
else if (VariableTwo < VariableOne && VariableTwo < VariableThree);
int Smallest = VariableTwo;
} else (VariableThree < VariableOne && VariableThree < VariableTwo);
int Smallest = VariableThree;
if (VariableOne < Biggest && VariableOne > Smallest){
int Mid = VariableOne;
else if (VariableTwo < Biggest && VariableTwo > Smallest);
int Mid = VariableTwo;
} else (VariableThree < Biggest && VariableThree > Smallest);
int Mid = VariableThree;
System.out.println(VariableOne + ", " + VariableTwo + ", " + VariableThree);
System.out.println(Biggest + ", " + Mid + ", " + Smallest);
}
}
;