Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ank.java import java.util.Hashtable; import java.util.Iterator; public class Bank { private Hashtable customers; private static int MAXCUSTOMERS = 30; private static double INTEREST_RATE = .03; public

ank.java

import java.util.Hashtable;

import java.util.Iterator;

public class Bank {

private Hashtable customers;

private static int MAXCUSTOMERS = 30;

private static double INTEREST_RATE = .03;

public Bank() {

customers = new Hashtable();

}

public boolean addCustomer(Customer aCustomer) {

int numberOfCustomers = customers.size();

if (numberOfCustomers >= MAXCUSTOMERS)

return false;

customers.put(aCustomer.getAccountNu... aCustomer);

return true;

}

public void removeCustomer(Customer aCustomer) {

customers.remove(aCustomer.getAccoun...

}

public void addInterest() {

Iterator i = customers.values().iterator();

while (i.hasNext()) {

Customer aCustomer = i.next();

aCustomer.deposit(aCustomer.getBala... * INTEREST_RATE);

}

}

public void showCustomers() {

Iterator i = customers.values().iterator();

while (i.hasNext()) {

Customer aCustomer = i.next();

System.out.println(aCustomer.toStri...

}

}

public static void main(String[] args) {

Customer customer1 = new Customer("Jake", "1", 100.00);

Customer customer2 = new Customer("Jack", "2", 100.00);

Customer customer3 = new Customer("John", "3", 100.00);

Customer customer4 = new Customer("Bob", "4", 100.00);

Customer customer5 = new Customer("Paul", "5", 100.00);

Customer customer6 = new Customer("Sarah", "6", 100.00);

Bank aBank = new Bank();

aBank.addCustomer(customer1);

aBank.addCustomer(customer2);

aBank.addCustomer(customer3);

aBank.addCustomer(customer4);

aBank.addCustomer(customer5);

aBank.addCustomer(customer6);

aBank.showCustomers();

aBank.addInterest();

aBank.showCustomers();

}

}

Customer.java

public class Customer {

private String name;

private String accountNumber;

private double balance;

public Customer(String name, String accountNumber, double balance) {

this.name = name;

this.accountNumber = accountNumber;

this.balance = balance;

}

public String getName() { return name; }

public String getAccountNumber() { return accountNumber; }

public double getBalance() { return balance; }

public void deposit(double amount) {

balance += amount;

}

public boolean withdraw(double amount) {

if (amount > balance)

return false;

balance -= amount;

return true;

}

public String toString() {

return "Name: " + name + " Account Number: " + accountNumber + " Balance: " + balance;

}

}

Bank.java:1: error: class, interface, or enum expected

ank.java

^

Bank.java:19: error: ')' expected

customers.put(aCustomer.getAccountNu... aCustomer);

^

Bank.java:19: error: not a statement

customers.put(aCustomer.getAccountNu... aCustomer);

^

Bank.java:19: error: ';' expected

customers.put(aCustomer.getAccountNu... aCustomer);

^

Bank.java:24: error: ')' expected

customers.remove(aCustomer.getAccoun...

^

Bank.java:31: error: ')' expected

aCustomer.deposit(aCustomer.getBala... * INTEREST_RATE);

^

Bank.java:31: error: illegal start of expression

aCustomer.deposit(aCustomer.getBala... * INTEREST_RATE);

^

Bank.java:31: error: ';' expected

aCustomer.deposit(aCustomer.getBala... * INTEREST_RATE);

^

Bank.java:39: error: ')' expected

System.out.println(aCustomer.toStri...

^

Customer.java:2: error: class, interface, or enum expected

Customer.java

^

1 error

These are my errors... what is wrong?

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

What is the per capita income of residents of Greenville?

Answered: 1 week ago

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago