0

Let's jump right in, shall we? Here is my code:

 import java.util.Scanner; 

public class a7main
{
    public static void main(String[] args)
    {
        double startBalance; 
        double annual_Interest_Rate; 
        int months; 
        double deposit_Amount; 
        double withdraw_Amount; 

        Scanner input = new Scanner(System.in); 

        System.out.print("Please enter your starting balance: $"); 
        startBalance = input.nextDouble(); 

        System.out.print("Please enter your annual interest rate: "); 
        annual_Interest_Rate = input.nextDouble(); 

        System.out.print("Please enter the number of months: ");
        months = input.nextInt(); 

        SavingsAccount sa = new
        SavingsAccount(startBalance, annual_Interest_Rate); 

        sa.setAnnualInterestRate(annual_Interest_Rate);

        for (int i = 0; i < months; i++)
        {
            System.out.print("Please enter the amount you would like to deposit for the month " + (i+1) + ":$"); 
            deposit_Amount = input.nextDouble(); 

            sa.setDeposit(deposit_Amount); 

            System.out.print("Please enter the amount you would like to withdraw for the month " + (i+1) + ":$"); 
            withdraw_Amount = input.nextDouble(); 

            sa.setWithdraw(withdraw_Amount); 

            sa.calculateMonthlyInterest();
        }
        sa.displayData(); 
    }
}

And here is the error message I get when I try to run it:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol symbol: class SavingsAccount
location: class a7main

I'm a complete beginner who hasn't encountered this error before. Any suggestions for how to address this error so that I can run this code?

Thank you.

J'on J'onzz
  • 11
  • 2
  • 5

4 Answers4

0

it seems that the compiler don't find the class SavingsAccount, is it included to your project ? you should import it just like you did here :

import java.util.Scanner; 
FrenchTechLead
  • 1,118
  • 3
  • 13
  • 20
0

I just got it to work! Apparently, my issue was due to the fact that I didn't manage my files properly and I proceeded in the wrong order. I had two files for this project, and I wrote the other one before I wrote this one. NetBeans proposed a solution, and when I clicked it to try it, it opened an additional project area for me to enter my code from the first file I had already created. When I copied it over, that fixed my problem.

Thanks for your other answers!

J'on J'onzz
  • 11
  • 2
  • 5
0

so, just add the class that is here:

https://codereview.stackexchange.com/questions/84551/savings-account-class-and-test-program

Here you will find SavingsAccount class.

Community
  • 1
  • 1
Timoshenko
  • 26
  • 5
0

As it is explained in other similar question, but for Windows:

  • close Netbeans
  • delete the folder $USER/AppData/Local/NetBeans/Cache/<your_Netbeans_version>/index
  • restart Netbeans

Original answer: “Uncompilable source code” RuntimeException in netbeans

abel.matos
  • 81
  • 1
  • 2