I am trying to get Java to identify triangles from input contained in a text file. I have the code for identifying triangles when a user inputs integers into the console but I want it to read the integers from a separate text file now. For some reason I am getting errors doing this like cannot read from the file. I added a file exception but all it did was println all three if statements. Any help would be appreciated. I just do not think the normal threads on opening a file have helped me.
import java.util.Scanner;
public class Triangle {
public static void main(String[] args) {
Scanner user = new Scanner(System.in);
double a, b, c;
System.out.println("Enter longest side: ");
a = user.nextDouble();
System.out.println("Enter second side: ");
b = user.nextDouble();
System.out.println("Enter third side: ");
c = user.nextDouble();
if (a == b && b == c) {
System.out.println("Equilateral Triangle");
} else {
if ((a == b && b !=c) || (a == c && a != b)) {
System.out.println("Isoceles Triangle");
}
if (a != b && b != c && a != c) {
System.out.println("Scalene Triangle");
}
if (((a + b) > (c)) && ((a + c) > b) && ((b + c) > a)) {
System.out.println("Not a Triangle");
}
}
}
}