Here is my code:
import java.util.Scanner;
import java.io.*;
public class Warning
{
public static void main (String[] args)throws IOException
{
int creditHrs;
double qualityPts;
double gpa;
String name;
// Set up scanner to input file
Scanner inFile = new Scanner(new File("c:\\students.dat"));
System.out.println ("\n Students on Academic Warning\n");
// Process the input file, one token at a time
try
{
while (inFile.hasNext())
{
// Get the credit hours and quality points and
// determine if the student is on warning. If so,
// display the student's name.
name = inFile.next();
creditHrs = Integer.parseInt(inFile.next());
qualityPts = Double.parseDouble(inFile.next());
gpa = qualityPts / creditHrs;
if(gpa < 2.0)
{
System.out.println(name);
}
}
}
//insert catch statements
catch(FileNotFoundException e)
{
}
catch(NumberFormatException e)
{
}
inFile.close();
}
}
The error is: error: exception FileNotFoundException is never thrown in body of corresponding try statement
Why am I getting this? I would think that it not throwing the exception is a good thing and why would it have to tell me that, you know? I really dont understand this.