Skip to Main Content

Java Development Tools

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!

Help for write Bank application in Java

919963Feb 25 2012 — edited Jul 2 2012
Hi.
I'm a student and I need write a programe bank application in java .
I must write a program that the customer could withdraw and deposit from his account.I wrote this program:
import java.util.Scanner;

public class BankAccount {

public static void main(String[] args) {
Scanner clapton=new Scanner(System.in);
int x;
float balance = 0;
boolean quit=false;
do {
System.out.println("1. Deposit money");
System.out.println("2. Withdraw money");
System.out.println("3. Check balance");
System.out.print(" 0 to quit: ");
System.out.println("enter your choice :");
x=clapton.nextInt();

if (x==1) {
float amount;
System.out.println(" enter your deposit money :");
amount=clapton.nextFloat();
balance + = amount;
}
else if (x==2) {
float amount;
System.out.println(" enter your Withdraw money :");
amount=clapton.nextFloat();
balance - = amount;
}
else if (x==3) {
System.out.println("your balance :" + balance );
}
else if (x==0) {
quit=true;
}
else {
System.out.println("wrong choice");
}

} while (!quit);
System.out.println("bye");
}
}

but I need to use several classes for this program. for exemple:
BankAccount which has an instance variable amount
and has methods:
withDraw which takes a parameter -> amountToWithDraw
deposit -> amountToAdd
checkBalance -> which takes no parameters, but which returns the value in the instance variable amount.
but i dont know how use of several classes.
you can help me?

Comments

Great article and project! I have a simple question. When you say:

Non-blocking request processing emerges as an effective way to address the problem. Instead of one blocking thread to handle one request, a small number of threads is used to handle a large number of requests asynchronously. This results in more efficient use of CPUs and better scalability, albeit at the cost of increased complexity.

Would you say then that we should not use server-side non-blocking processing if performance is not an issue? For the applications I work on, load is very predictable and low. It seems to me that in these cases the increased complexity is not worth it. (I contrast this to AJAX. AJAX enables web applications to do more work faster and responsively, but even if your web application has very little work to do, the user experience of AJAX applications is often superior to applications that do not use AJAX due to full page refreshes.)

Antón R. Yuste

Superb article, thanks!

user11017489

Thank you for this beautiful summary.

Re Lai-Oracle

Great article and project! I have a simple question. When you say:

Non-blocking request processing emerges as an effective way to address the problem. Instead of one blocking thread to handle one request, a small number of threads is used to handle a large number of requests asynchronously. This results in more efficient use of CPUs and better scalability, albeit at the cost of increased complexity.

Would you say then that we should not use server-side non-blocking processing if performance is not an issue? For the applications I work on, load is very predictable and low. It seems to me that in these cases the increased complexity is not worth it. (I contrast this to AJAX. AJAX enables web applications to do more work faster and responsively, but even if your web application has very little work to do, the user experience of AJAX applications is often superior to applications that do not use AJAX due to full page refreshes.)

Thank you. And yes, I'd think so. Asynchronous programming is harder to reason about.

lprimak

There is more hype in asynchronous / non-blocking programing than is proven by benchmarks or common sense:

Mohan Basavarajappa

Hi @"Yolande Poirier-Oracle"

informative article contributed. provides information on what all NIO frameworks are available and what is the high-level difference. More over it provides the advancements and where platform is headed. Nice samples too to get kick started with learning.

We are in the process of fixing the code layout. Sorry for the convenience.

Redfred Garett

Excellent article. Really very useful. Thanks !!!

1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 30 2012
Added on Feb 25 2012
4 comments
1,013 views