Question
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
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
while (i.hasNext()) {
Customer aCustomer = i.next();
aCustomer.deposit(aCustomer.getBala... * INTEREST_RATE);
}
}
public void showCustomers() {
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started