Question: When attempting to compile my main Java program (to be used with a class) I receive: Test.java:17: error: cannot find symbol SavClass c = new

When attempting to compile my main Java program (to be used with a class) I receive:

Test.java:17: error: cannot find symbol

SavClass c = new SavClass(startBalance,intRate);

^ symbol: variable startBalance

location: class PTest

1 error

The compiler (jGRASP) seems to be saying that I need to declare a variable. However, other programs I have downloaded don't seem to need a variable declared when creating an object with the class. How can I fix this error. I have tried compiling this on a Windows 7 and 10 PCs but have the same error.

//Main program

import java.util.Scanner;

public class PTest{

public static void main(String[] args)

{

double bal = 0.00;

double intRate = 0.00;

int months = 0;

double depAmount;

double withAmount;

double totalDeposits = 0.00;

double totalWithdrawn = 0.00;

Scanner keyboard = new Scanner(System.in);

SavClass c = new SavClass(startBalance,intRate);

}

}

//Class

public class SavClass

{

private double balance;

private double withdraw;

private double deposit;

private double interestRate;

private double interest;

private double totalDeposits;

private double totalWithdrawn;

private double startBalance;

public SavClass (double startBalance,double intRate)

{

balance = startBalance;

interestRate = intRate;

interest = 0.00;

}

public double getBalance()

{

return balance;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!