please help me code written but I have a problem
I have java creator and I did this first class that I can compile bankAccount which is my base class,why can t I compile the second class that I did on a second program which is SavingsAccount trying to extend the bankAccount class. Thank you for your help...
/**
* AWT Sample application
*
* @author
* @version 1.00 07/02/04
*/
public abstract class BankAccount
{
double Balance, AnnualInterestRate, MonthlyServiceCharge = 0;
int NumberOfDepositThisMonth = 0, NumberOfWithdrawls = 0;
public BankAccount(double newBalance, double newAnnualInterestRate)
{
Balance = newBalance;
AnnualInterestRate = newAnnualInterestRate;
}
public void Deposit(double AmountOfDeposit)
{
double newAmount;
newAmount = AmountOfDeposit + Balance;
++NumberOfDepositThisMonth;
}
public void Withdrawals(double AmountOfTheWithdrawal)
{
Balance = Balance - AmountOfTheWithdrawal;
++NumberOfWithdrawls;
}
public void CalcInterest(double MonthlyInterestRate, double MonthlyInterest)
{
MonthlyInterestRate = (AnnualInterestRate/12);
MonthlyInterest = Balance * MonthlyInterestRate;
Balance = Balance + MonthlyInterest;
}
public void MonthlyProcess()
{
Balance = Balance - MonthlyServiceCharge;
this.CalcInterest(0,0);
}
}
And the second program
/**
* AWT Sample application
*
* @author
* @version 1.00 07/02/04
*/
import java.util.*;
public class SavingsAccount extends BankAccount
{
boolean StatusOfAccountActive = (Balance >= 25);
// default constructor for SavingsAccount class - added
public SavingsAccount()
{
super();
}
// in your withdrawals method, you left the parenthesis without any parameters
// this withdrawals method should also have a double parameter that you pass to it
public void Withdrawals(double w)
{
if(StatusOfAccountActive)
super.Withdrawals(w);// because I declared w as a double, you can now pass it to the
// super method
// also check your spelling
// you spelled Withdrawals different
else
System.out.println("Your account is now inactive, needs a balance over 25$, thank you.");
}
public void Deposit(double d)// since Deposit is inherited from BankAccount class you should also
// keep the number of parameters the same
{
if(StatusOfAccountActive)
super.Deposit(d);
else
System.out.println("Your account is now inactive, needs a balance over 25$, thank you.");
}
public void MonthlyProcess()
{
if(NumberOfWithdrawls > 2)// i added NumberOfWithdrawls here
++ MonthlyServiceCharge;
else;
}
}
[2930 byte] By [
alan-3522a] at [2007-11-26 17:34:05]

the error message is:
--Configuration: SavingsAccount - JDK version 1.5.0_03 <Default> - <Default>--
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\SavingsAccount\src\SavingsAccount.java:9: cannot find symbol
symbol: class BankAccount
public class SavingsAccount extends BankAccount
^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\SavingsAccount\src\SavingsAccount.java:11: cannot find symbol
symbol : variable Balance
location: class SavingsAccount
boolean StatusOfAccountActive = (Balance >= 25);
^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\SavingsAccount\src\SavingsAccount.java:24: call to super must be first statement in constructor
super(Withdrawals);// because I declared w as a double, you can now pass it to the
^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\SavingsAccount\src\SavingsAccount.java:36: cannot find symbol
symbol : variable super
location: class SavingsAccount
super.Deposit(d);
^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\SavingsAccount\src\SavingsAccount.java:43: cannot find symbol
symbol : variable NumberOfWithdrawls
location: class SavingsAccount
if(NumberOfWithdrawls > 2)// i added NumberOfWithdrawls here
^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\SavingsAccount\src\SavingsAccount.java:44: cannot find symbol
symbol : variable MonthlyServiceCharge
location: class SavingsAccount
++ MonthlyServiceCharge;
^
6 errors
Process complete
* AWT Sample application
*
* @author
* @version 1.00 07/02/04
*/
import java.util.*;
public class SavingsAccount extends BankAccount
{
boolean StatusOfAccountActive = (Balance >= 25);
// default constructor for SavingsAccount class - added
public SavingsAccount()
{
super();
}
// in your withdrawals method, you left the parenthesis without any parameters
// this withdrawals method should also have a double parameter that you pass to it
public void Withdrawals(double w)
{
if(StatusOfAccountActive)
super.Withdrawals(w);// because I declared w as a double, you can now pass it to the
// super method
// also check your spelling
// you spelled Withdrawals different
else
System.out.println("Your account is now inactive, needs a balance over 25$, thank you.");
}
public void Deposit(double d)// since Deposit is inherited from BankAccount class you should also
// keep the number of parameters the same
{
if(StatusOfAccountActive)
super.Deposit(d);
else
System.out.println("Your account is now inactive, needs a balance over 25$, thank you.");
}
public void MonthlyProcess()
{
if(NumberOfWithdrawls > 2)// i added NumberOfWithdrawls here
++ MonthlyServiceCharge;
else;
}
}
> the error message is:
>
> --Configuration: SavingsAccount -
> JDK version 1.5.0_03 <Default> -
> <Default>--
> C:\Program Files\Xinox
> Software\JCreatorV3LE\MyProjects\SavingsAccount\src\Sa
> vingsAccount.java:9: cannot find symbol
> symbol: class BankAccount
> public class SavingsAccount extends BankAccount
Exactly like the error message says: It doesn't know anything about the BankAccount class.
[url=http://wiki.java.net/bin/view/Javapedia/ClassPath]Javapedia: Classpath[/url]
[url=http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html]How Classes are Found[/url]
[url=http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html]Setting the class path (Windows)[/url]
[url=http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html]Setting the class path (Solaris/Linux)[/url]
[url=http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html]Understanding the Java ClassLoader[/url]
java -cp .;<any other directories or jars> YourClassName
You get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
javac -classpath .;<any additional jar files or directories> YourClassName.java
You get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.