The file is in my project, and named correctly, I am quite new to JAVA. Any hints would be appreciated, TIA.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ExceptionsAndCarryOn {
public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub
Scanner UserInput = new Scanner(new File("Numbers.txt"));
System.out.println("Please enter the numbers: ");
int [] numbers = new int [5];
int i = 0;
while(UserInput.hasNextInt()){
numbers[i++] = UserInput.nextInt();
}
int sum = 0;
for ( i = 0; i < numbers.length; i++)
sum += numbers[i];
System.out.println(sum);
UserInput.close();
}
}