Question: class Account { private String name; private double balance; public Account(String name, double balance) { this.name = name; this.balance = balance; } public String getName()
class Account {
private String name;
private double balance;
public Account(String name, double balance) {
this.name = name;
this.balance = balance;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public void deposit(double amount) {
balance += amount;
}
public void withdrawal(double amount) {
if (balance >= amount) {
balance -= amount;
} else {
System.out.println(" Insuficient Balance. ");
}
}
}
class Bank {
ArrayList
Scanner input = new Scanner(System.in);
int userInput;
Scanner q;
String name;
double balance;
public void enterCustomers() {
System.out.println("Enter customer names or press q to quit entering names: ");
while(true) {
String name;
double balance;
System.out.print("Enter a customer name: ");
name = input.next();
if ("q".equalsIgnoreCase(name))
break;
System.out.print("Enter the opening balance : ");
balance = input.nextDouble();
accounts.add(new Account(name, balance));
}
}
usin the account class and bank class given can someone please create a banking method that will be able to deposit or withdraw an amount to or from the account. use an integer to select to (1) deposit, (2) withdraw or (0) quit; It will continue to repear options till 0 is pressed to quit; you should not relay on the order/index of the list to determine the customers account. You should make sure the accounts name matches the customers name. just please use sime if switch do and while statements only thanks.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
