I need to create a bank account class which consists of deposit and withdraw methods. I need to have classes that inherit from superclass, a current account and savings account and a test/driver class that calls all methods and operates the system?

something like:

public abstract class BankAccount {
private double balance;
public BankAccount() {
balance = 0.;
}
public void deposit(double amount) {
balance += amount;
}
public withdraw(double amount) {
// check...
balance -= amount;
}
}
public class CurrentAccount extends BankAccount {
// additional stuff
}
public class SavingsAccount extends BankAccount {
// aditional stuff
}

Recommended Answers

All 5 Replies

So far the code seems ok. Just add the 'void' keyword at the withdraw method and add a get method that returns the balance.
Then create a main method and instantiate the classes: CurrentAccount and/or SavingsAccount and call their methods and print the balance.

How would i call the methods from the main and ask the user which accouunt they would like to deposit or withdraw?

How to call methods is in every basic java book there is. Instead of asking someone to tell you that, do some studying.

If you want to ask the user for input then use the Scanner class. Search for examples in this forum.

hello..
please help me..
how to write java program to count total of money after we make a transaction?

this is what must we have in java program :

- program to count balance money in account bank.
-we must set default value for the total money in account bank

what we must have in a program is :

1) method for deposit
2)metod for take a money from account
3) method for show balance money after transaction

commented: Don't hi-jack the thread! +0

hello..
please help me..
how to write java program to count total of money after we make a transaction?

this is what must we have in java program :

- program to count balance money in account bank.
-we must set default value for the total money in account bank

what we must have in a program is :

1) method for deposit
2)metod for take a money from account
3) method for show balance money after transaction

Do some studying, read your notes and post code in a NEW thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.