| | |
Java BankAccount program
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
hmm, is it the start of the new school year where you are?
Get a good book, there's at least one I know of that develops just that as one of its core example applications, good luck in finding it (will give you at least some work to do before you turn in the code verbatim as your own)
Get a good book, there's at least one I know of that develops just that as one of its core example applications, good luck in finding it (will give you at least some work to do before you turn in the code verbatim as your own)
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
Hi everyone,
I remember doing some simple banking programs thread some where else and here is the link
http://wizardsolutionsusa.com/progra...topic.php?t=59
I hope this has helped you
Thank You
Yours Sincerely
Richard West
I remember doing some simple banking programs thread some where else and here is the link
http://wizardsolutionsusa.com/progra...topic.php?t=59
I hope this has helped you
Thank You
Yours Sincerely
Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
•
•
Join Date: Aug 2005
Posts: 10
Reputation:
Solved Threads: 0
Here's the program that I wrote, but I'm having problems with my ending balance and overdraft fee. The overdraft fee is multiplied by whatever amount I enter: can some help; here's the program:
import java.io.*;
import java.lang.*;
public class BankAccount5
{
public static void main(String[]args)throws IOException
{
char [] newType = new char [20];
double [] newTransaction = new double [20];
double [] newBalance = new double [20];
int o = 0;
int s = 0;
int t = 0;
BufferedReader console = new BufferedReader (
new InputStreamReader(System.in));
System.out.println(" Enter Your Name");
String name = console.readLine();
System.out.println("Hello " + name);
System.out.println(name +" " + "enter your account number");
String account = console.readLine();
System.out.println(" enter your original balance");
String Bal = console.readLine();
double initialBalance = Double.parseDouble(Bal);
double balance = initialBalance;
System.out.println("Enter c for Check; d for Deposit; or p to Print Summary");
char continueAnswer = console.readLine().charAt(0);
boolean answer = true;
newType [o] = continueAnswer;
if (continueAnswer == 'p')answer = false;
double Fee;
double OverdraftTotal = 0;
double checks = 0;
double deposit = 0;
double TotalBalance = 0;
while (answer == true)
{
System.out.println("Enter amount");
String input = console.readLine();
double transaction = Double.parseDouble(input);
newTransaction [o] = transaction;
if (continueAnswer == 'c')
checks = checks + transaction;
{
checks = checks + 0;
if (transaction > balance)
{
if (transaction > 250)
Fee = transaction * .10;
else
Fee = 25.00;
balance = (balance + transaction) - Fee;
newBalance [t] = TotalBalance;
OverdraftTotal = OverdraftTotal + Fee;
o = o + 0;
t = t + 0;
newType [o] = 'f';
newTransaction [o] = Fee;
}
else
balance = balance - transaction;
newBalance [t] = balance;
}
if (continueAnswer == 'd')
deposit = deposit + transaction;
balance = deposit + transaction;
newBalance [t] = balance;
o = o + 0;
t = t + 1;
System.out.println("Enter c for Check; d for Deposit; or p to Print Summary");
continueAnswer = console.readLine().charAt(0);
newType [o] = continueAnswer;
if (continueAnswer == 'p')answer = false;
}
if (balance <= 0)
System.out.println("Your account insufficient, You should enter $" + balance + " to bring account current");
System.out.println("Name " + name + ", Account Number " + account);
System.out.println(" Account Statement");
System.out.println("Your balance " + balance);
System.out.println("Amount of checks: " + checks);
System.out.println("Overdraft total fees: $" + OverdraftTotal);
System.out.println("Total Checks: $" + checks);
System.out.println("Total Deposits: $" + deposit);
while (s < o)
{
System.out.println(newType[s] + " " + newTransaction [s] + " " + newBalance[s]);
s = s + 1;
System.out.println("");
}
}
}
import java.io.*;
import java.lang.*;
public class BankAccount5
{
public static void main(String[]args)throws IOException
{
char [] newType = new char [20];
double [] newTransaction = new double [20];
double [] newBalance = new double [20];
int o = 0;
int s = 0;
int t = 0;
BufferedReader console = new BufferedReader (
new InputStreamReader(System.in));
System.out.println(" Enter Your Name");
String name = console.readLine();
System.out.println("Hello " + name);
System.out.println(name +" " + "enter your account number");
String account = console.readLine();
System.out.println(" enter your original balance");
String Bal = console.readLine();
double initialBalance = Double.parseDouble(Bal);
double balance = initialBalance;
System.out.println("Enter c for Check; d for Deposit; or p to Print Summary");
char continueAnswer = console.readLine().charAt(0);
boolean answer = true;
newType [o] = continueAnswer;
if (continueAnswer == 'p')answer = false;
double Fee;
double OverdraftTotal = 0;
double checks = 0;
double deposit = 0;
double TotalBalance = 0;
while (answer == true)
{
System.out.println("Enter amount");
String input = console.readLine();
double transaction = Double.parseDouble(input);
newTransaction [o] = transaction;
if (continueAnswer == 'c')
checks = checks + transaction;
{
checks = checks + 0;
if (transaction > balance)
{
if (transaction > 250)
Fee = transaction * .10;
else
Fee = 25.00;
balance = (balance + transaction) - Fee;
newBalance [t] = TotalBalance;
OverdraftTotal = OverdraftTotal + Fee;
o = o + 0;
t = t + 0;
newType [o] = 'f';
newTransaction [o] = Fee;
}
else
balance = balance - transaction;
newBalance [t] = balance;
}
if (continueAnswer == 'd')
deposit = deposit + transaction;
balance = deposit + transaction;
newBalance [t] = balance;
o = o + 0;
t = t + 1;
System.out.println("Enter c for Check; d for Deposit; or p to Print Summary");
continueAnswer = console.readLine().charAt(0);
newType [o] = continueAnswer;
if (continueAnswer == 'p')answer = false;
}
if (balance <= 0)
System.out.println("Your account insufficient, You should enter $" + balance + " to bring account current");
System.out.println("Name " + name + ", Account Number " + account);
System.out.println(" Account Statement");
System.out.println("Your balance " + balance);
System.out.println("Amount of checks: " + checks);
System.out.println("Overdraft total fees: $" + OverdraftTotal);
System.out.println("Total Checks: $" + checks);
System.out.println("Total Deposits: $" + deposit);
while (s < o)
{
System.out.println(newType[s] + " " + newTransaction [s] + " " + newBalance[s]);
s = s + 1;
System.out.println("");
}
}
}
•
•
Join Date: May 2005
Posts: 55
Reputation:
Solved Threads: 1
1. Shouldn't TotalBalance start off with the initial balance?
2. When there are insufficient funds for a check, shouldn't the original transaction be cancelled and only the overdraft charge applied?
3. Near line 78, it appears that you are missing the { } for the if.
The third line below is always executing even during withdrawals.
4. Near line 82, Shouldn't o also be incremented as well? It is the transaction counter right?
For more help, www.NeedProgrammingHelp.com
Java Syntax (Toggle Plain Text)
double TotalBalance = initialBalance //not: double TotalBalance = 0
2. When there are insufficient funds for a check, shouldn't the original transaction be cancelled and only the overdraft charge applied?
Java Syntax (Toggle Plain Text)
balance = (balance) - Fee; //not: balance = (balance + transaction) - Fee;
3. Near line 78, it appears that you are missing the { } for the if.
The third line below is always executing even during withdrawals.
Java Syntax (Toggle Plain Text)
if (continueAnswer == 'd') deposit = deposit + transaction; balance = deposit + transaction;
4. Near line 82, Shouldn't o also be incremented as well? It is the transaction counter right?
Java Syntax (Toggle Plain Text)
o = o + 0; t = t + 1;
•
•
Join Date: Jun 2005
Posts: 28
Reputation:
Solved Threads: 0
You have written all the code in single program.
Why not break the logic for withraw, deposit, inquire balance, etc. operations into seperate methods.
-------------------------------
Programming (Assignment/Project) Help
Why not break the logic for withraw, deposit, inquire balance, etc. operations into seperate methods.
-------------------------------
Programming (Assignment/Project) Help
![]() |
Similar Threads
- bankaccount program (Java)
- bankaccount program (Java)
Other Threads in the Java Forum
- Previous Thread: help.. methods/argument list
- Next Thread: Java novice PLEASE HELP!!!
Views: 8998 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for Java
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class classes client code component database derby design draw eclipse encryption error event exception file fractal game givemetehcodez google graphics gui helpwithhomework html ide if_statement image input integer interface j2me java javadesktopapplications javaprojects jmf jni jpanel julia linux list loop map method methods midlethttpconnection mobile multithreading netbeans newbie number object oracle print printing problem program programming project recursion reference remove ria scanner screen search server set size sms socket sort sourcelabs sql stop string swing test threads time tree ui unicode validation windows






