Here is the piece of code I'm working with
import java.util.*;
public class FinalExam
{
public static void main (String[] args)
{
double amount = 0;
SavingsAccount penny = new SavingsAccount("Penny Saved", 500.00, .05);
Scanner input = new Scanner(System.in);
System.out.print("Enter your deposit amount: ");
try
{
amount = input.nextDouble();
penny.deposit(amount);
}
catch(NegativeAmountException e)
{
System.out.println("NegativeAmountException: " + e.getMessage());
System.exit(1);
}
System.out.print("Enter your withdraw amount: ");
try
{
amount = input.nextDouble();
penny.withdraw(amount);
}
catch(NegativeAmountException e)
{
System.out.println("NegativeAmountException: " + e.getMessage());
System.exit(1);
}
catch(InsufficientFundsException e)
{
System.out.println("InsufficientFundsException: " + e.getMessage());
System.exit(1);
}
}
}
When I try to compile the code I get the error message:
FinalExam.java:8: error: unreported exception NegativeAmountException; must be caught or declared to be thrown SavingsAccount penny = new SavingsAccount("Penny Saved", 500.00, .05); ^ 1 error
I'm not really sure how to fix this error. Any advice will help.
Thanks