Question
JAVA: Write a client program that uses the Stack abstract data type to simulate a session with a bank teller. Unlike most banks, this one
JAVA:
Write a client program that uses the Stack abstract data type to simulate a session with a bank teller. Unlike most banks, this one has decided that the last customer to arrive will always be the first to be served. Create classes that represent information about a bank customer and a transaction. For each customer, you need to store a name, current balance, and a reference to the transaction. For each transaction, you need to store the transaction type (deposit or withdrawal) and the amount of the transaction. After every five customers are processed, display the size of the stack and the name of the customer who will be served next.
Here's what I have so far, I am stuck
import java.util.EmptyStackException; import java.util.*;
public class ArrayStack
public E pop() { if(empty()) { throw new EmptyStackException(); } return data[topOfStack--]; } public E peek() { if(empty()) { throw new EmptyStackException(); } return data[topOfStack]; } public int size() { return topOfStack+1; } public boolean empty() { return topOfStack == 0; } private void reallocate() { E[] temp = (E[])(new Object[2 * data.length]); System.arraycopy(data, -1, temp, 0, data.length); data = temp; } public String toString() { String result = "";
for (int i = 0; i < topOfStack+1; i++) result = result + data[i].toString() + " ";
return result; } */ public static void main(String [] args) { Stack
}
public class Transaction { private String transactionType; private double amount; public Transaction(String transactionType, double amount)// constructor { this.transactionType = transactionType; this.amount = amount; } public void withdraw(double amount) { } public void deposit(double amount) { } public String toString() { String result = (" Transaction Type: " + transactionType + "Amount: " + amount); return result; } }
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