I am new to java as the name states. I am attempting a program where you need to input three numbers from a file and list them in ascending order. I need to use if and if else statements only, no arrays. Not sure where I went wrong on it but any help would be great.
import java.io.*; import java.util.*; public class AscendingOrder { public static void main(String[]args) throws FileNotFoundException { double num1, num2, num3; Scanner inFile = new Scanner(new FileReader("c:\\numbers.text")); num1 = inFile.nextDouble(); num2 = inFile.nextDouble(); num3 = inFile.nextDouble(); if ((num1 < num2) && (num1 < num3)) { System.out.print("The numbers in ascending order are: " + num1); else if (num2 < num3) System.out.println(" " + num2 + " " + num3); else System.out.println(" " + num3 + " " + num2); } if ((num2 < num1) && (num2 < num3)) { System.out.print("The numbers in ascending order are: " + num2); else if (num1 < num3) System.out.println(" " + num1 + " " num3); else System.out.println(" " + num3 + " " num1); } if ((num3 < num1) && (num3 < num2)) { System.out.print("The numbers in ascending order are: " + num3); else if (num1 < num2) System.out.println(" " + num1 + " " + num2); else System.out.println(" " + num2 + " " + num1); } inFile.close(); } }