hi I need a java program that will use parallel array to hold an account number, account holders name, withraw, deposit, intial balance, balance and overdraft fee. It must also print out the account number, account holders name and balance.


thanks

Recommended Answers

All 7 Replies

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) :)

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("");
        }
}
}

1. Shouldn't TotalBalance start off with the initial balance?

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?

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.

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?

o = o + 0;
t = t + 1;

For more help, www.NeedProgrammingHelp.com

mmm..tough problem

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

Where's the snychronization? Your balance can become negative if you don't sync it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.