How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Todd Your Own Question
Todd, Computer Software Engineer
Category: Programming
Satisfied Customers: 422
Experience:  PHP, Ruby, Python, C#, C, C++, Java, CSS, HTML, JavaScript.
Type Your Programming Question Here...
Todd is online now
A new question is answered every 9 seconds

Write a Java program to simulate a bank account. The bank

Resolved Question:

Write a Java program to simulate a bank account. The bank account class should have at least following three operations: deposit, withdraw, and display (balance as well as history of transactions). Assume overdraft is not allowed and the maximum number of transactions is 10. All monetary values used here are floating point type.

1. In the bankAccount class, you should have one variable called totalBalance to balance of an account, a static variable called totalAccounts to track how many accounts have been created, and an array called transactionHistry that recorded the history of transactions associated with that account;

2. Write a constructor using key word this when you initialize the variable totalBalance with the initial value passed as the argument to the constructor. The static variable totalAcounts should be updated within the constructor as well;

3. Implement the deposit and withdraw methods by updating the variable totalBalance and the array transactionHistry;

4. Implement the display methods so that the information like follows will be printed out on the screen:

totalAccounts: 1;
Information about current bank account:
totalBalance: $134.45
deposit: $100.00;
withdraw: $-15.00
withdraw: $-6.10

5. Use Object-Oriented Programming technique to write a test program, which should run each operation at least once.

Critical thinking
In order to make your program robust, you need to think different scenarios such as:

1. How to enforce the overdraft protection?

2. What if the use input a negative number other than a positive number as the input to your methods?

3. What if a user tries to do transactions when they reach the maximum already?

4. Where should we initialize the static variable totalAccounts?
Submitted: 7 years ago.
Category: Programming
Expert:  Todd replied 7 years ago.
I will have this ready within the hour for you.
Customer: replied 7 years ago.
Expert:  Todd replied 7 years ago.
Find the files at
Customer: replied 7 years ago.
Reviewing now...will get right back with you for questions.
Customer: replied 7 years ago.
Hey Todd,

I'm trying to run the program in "eclipse" and I'm getting the following error.

Launch error - selection does not contain a main type.

I'm not a professional java developer as i'm taking a course, so I need a little help.

Please advise.
Expert:  Todd replied 7 years ago.
Are you running the BankAccountDriver class? It is the class that needs to be launched as it contains the main method, i.e. the method that is the entry point to your application. Also, ensure that both Java files are in the project.
Customer: replied 7 years ago.

I wasn't runnign the BankAccountDriver class.

This is an entry level Java programming class so I need the main method to be inserted into (1) file.

I'm sure you are offering professional next level programming, but can we get it all 1 .java file?
Expert:  Todd replied 7 years ago.
Find the single with everything in the same class at

Edited by Todd A. on 11/30/2009 at 8:50 PM EST
Todd and other Programming Specialists are ready to help you
Customer: replied 7 years ago.
Thanks Todd.

I'm going to play around with it, but you have given me a great base to work from.