I'm new to Java and coding in general and I just can't get what I messed up here. I'm using Eclipse and I'm trying to get it to read from a simple text file that has two numbers in it "54 0.0" written just like that. I have the text file "ClimateData" saved right next to the this java file in the src folder and it still won't run the program. I don't know what I've done wrong
import java.util.Scanner;
import java.io.*;
public class ClimateSummary
{
public static void main (String [] args) throws FileNotFoundException
{
Scanner textFile = new Scanner (new File("ClimateData"));
int inputTemperature = textFile.nextInt();
double inputPercipitation = textFile.nextDouble();
if (inputTemperature > 90) {
System.out.print("It's miserably hot out man, ");
} else if (inputTemperature < 90 && inputTemperature > 80) {
System.out.print("It's kind of hot, ");
} else if (inputTemperature < 80 && inputTemperature > 60) {
System.out.print("It's pretty nice out, ");
} else if (inputTemperature < 60 && inputTemperature > 32) {
System.out.print("It's a bit cold out, ");
} else if (inputTemperature < 32) {
System.out.print("It's miserably c-c-co-cold bro, ");
}
if (inputPercipitation > .1) {
System.out.print("and it's a little rainy.");
} else if (inputPercipitation <= .1) {
System.out.print("it's not rainy.");
}
textFile.close();
}
}
I get this error:
Exception in thread "main" java.io.FileNotFoundException: ClimateData (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at ClimateSummary.main(ClimateSummary.java:11)