Welcome to the forums. Please read
this topic to learn how to post code in code or highlight tags and other useful info for new members.
The first step in debugging to look at the stack trace and analyse the run time exception
So a 'NumberFormatException' is being thrown at Line 42 in Mileage.java. Turn on line numbers in your IDE and look at that line of code.
milesPergallon = Integer.parseInt(milesDriven) / Integer.parseInt(gallonsUsed);
If you don't see anything immediately wrong with this code then take a look at the API documentation for the calls you are making. Here is a link to
Integer.parseInt. Have a close read. Now obviously this isn't the correct method for what you want but for educational purposes lets continue with this line of debugging. One thing that the docs say is that it will throw a NumberFormatException if the String does not contain a parsable int. So one thing we could do is catch that exception.
Run the program again with the same inputs. It doesn't solve the problem but at least it doesn't crash the program and gives us a way of gracefully dealing with the exception.
Next up it's time for the debugger. All good IDE's have breakpoints. Put a breakpoint in on the problematic line and inspect the values of the variables. Now step over that line of code and see what happens. In this case you will see that Integer.parseInt(gallonsUsed) throws a NumberFormatException because it is equal to 25.5 and parseInt expects a whole number.
This process isn't unique to your code, you will use the same basic process for pretty much every run time exception you will encounter.