Results 1 to 5 of 5
- 02-26-2012, 02:22 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
Help for write Bank application in Java
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.
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?
Java Code: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(" Amount to deposit :"); amount=clapton.nextFloat(); if (amount>=0) { balance += amount; } else { System.out.println("system can't reply your request"); } } else if (x==2) { float amount; System.out.println(" Amount to withdraw :"); amount =clapton.nextFloat(); if (amount<=0 || amount > balance) { System.out.println("system can't reply your request "); } else { 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"); } }Last edited by Norm; 02-26-2012 at 05:30 PM. Reason: changed quote to code tags
- 02-26-2012, 03:15 PM #2
Re: Help for write Bank application in Java
Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Well you need to use objects... I guess?Last edited by santa; 02-26-2012 at 03:21 PM.
- 02-26-2012, 03:53 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
Re: Help for write Bank application in Java
you can say how I use objects for this program?
- 02-26-2012, 07:49 PM #4
Re: Help for write Bank application in Java
Each account can be viewed as an Object ... check the link i provided
- 02-26-2012, 08:27 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
Re: Help for write Bank application in Java
Object oriented programming starts with realizing that you don't just have to specify what needs to be done, but also who (or what again) needs to do it. In your program everything is done in a main( ... ) method.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
help java bank....
By natsuki in forum IntroductionsReplies: 2Last Post: 07-25-2011, 03:36 AM -
java bank account problem
By awil121 in forum New To JavaReplies: 1Last Post: 10-13-2010, 10:47 PM -
Create a java class for a bank account!!?
By singh345 in forum New To JavaReplies: 1Last Post: 03-17-2010, 04:26 PM -
Java Question Bank
By mgm2010 in forum New To JavaReplies: 2Last Post: 07-31-2009, 06:45 PM -
java program for updating bank details
By java__beginner in forum New To JavaReplies: 5Last Post: 03-12-2009, 03:42 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks