Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The L&L bank can handle up to 30 customers who have savings accounts. Design and implement a program that manages the accounts. Keep track of

The L&L bank can handle up to 30 customers who have savings accounts. Design and implement a program that manages the accounts. Keep track of key information and let each customer make deposits and withdrawals. Produce error messages for invalid transactions. Hint: You may want to base your accounts on the Account class from chapteer 5. Also provide a method to add 3 percent interest to all accounts whenever the method is invoked.

this is the account class in chapter 5:

import java.text.NumberFormat; public class Accounts { private NumberFormat fmt = NumberFormat.getCurrencyInstance(); private final double RATE = 0.035; // interest rate of 3.5% private int acctNumber; private double balance; private String name; //----------------------------------------------------------------- // Sets up the account by defining its owner, account number, // and initial balance. //----------------------------------------------------------------- public Accounts (String owner, int account, double initial) { name = owner; acctNumber = account; balance = initial; } //----------------------------------------------------------------- // Validates the transaction, then deposits the specified amount // into the account. Returns the new balance. //----------------------------------------------------------------- public double deposit (double amount) { if (amount < 0) // deposit value is negative { System.out.println (); System.out.println ("Error: Deposit amount is invalid."); System.out.println (acctNumber + " " + fmt.format(amount)); } else balance = balance + amount; return balance; } //----------------------------------------------------------------- // Validates the transaction, then withdraws the specified amount // from the account. Returns the new balance. //----------------------------------------------------------------- public double withdraw (double amount, double fee) { amount += fee; if (amount < 0) // withdraw value is negative { System.out.println (); System.out.println ("Error: Withdraw amount is invalid."); System.out.println ("Account: " + acctNumber); System.out.println ("Requested: " + fmt.format(amount)); } else if (amount > balance) // withdraw value exceeds balance { System.out.println (); System.out.println ("Error: Insufficient funds."); System.out.println ("Account: " + acctNumber); System.out.println ("Requested: " + fmt.format(amount)); System.out.println ("Available: " + fmt.format(balance)); } else balance = balance - amount; return balance; } //----------------------------------------------------------------- // Adds interest to the account and returns the new balance. //----------------------------------------------------------------- public double addInterest () { balance += (balance * RATE); return balance; } public double addInterestAll ()// I made this method myself but I am not sure if it is correct { balance += (balance * 0.03); return balance; } //----------------------------------------------------------------- // Returns the current balance of the account. //----------------------------------------------------------------- public double getBalance () { return balance; } //----------------------------------------------------------------- // Returns the account number. //----------------------------------------------------------------- public int getAccountNumber () { return acctNumber; } //----------------------------------------------------------------- // Returns a one-line description of the account as a string. //----------------------------------------------------------------- public String toString () { return (acctNumber + "\t" + name + "\t" + fmt.format(balance)); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions