Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

creating classes with void methods

807588Feb 19 2009 — edited Feb 19 2009
How are you everyone?
I'm stuck in a rut:i've been trying to create a class with void methods and i can't seem to call the methods successfully from another class.
The question im working on is as follows:

Create a class called BankAccount.It should have the following properties:
1)Two State Variables:
balance...double-How much money is currently in the account.
name...String.The name of the person owning the account.

2)Constructor should accept two parameters.
a)a double variable that is used to initialise the state variable balance
b)The other should be a String that is used to initialise the state variable,*name*

3)Two methods:
deposit...returns nothing...accepts a double that is the amount of money being deposited.It's added to the balance to produce a new balance.

withdraw...returns nothing..accepts a double that is the amount of money being taken out of the account.It's subtracted from the balance to produce a new balance

The second class is of the following architecture:
Create a Tester class that has a main() method.In that method you should input from the keyboard the amount(1000)of money to be put into the account(via the constructor)along with the name of the person to whom the account belongs.
1)Use these two pieces of data to create a new BankAccount+ object called myAccount+

2)Call the deposit method to deposit $505.22.

3)Print the balance state variable.

4)Call the withdraw method to withdraw $100.

5)Print the remaining balance in this form:
The Sally Jones Account balance is, $1405.22.

Thank you all,Ceekavilla.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2009
Added on Feb 19 2009
17 comments
608 views