This banking system is to be created for this assignment. The program will consi
ID: 3791278 • Letter: T
Question
This banking system is to be created for this assignment. The program will consist of five(5)classes: Mustang Banking (which will contain the main method), Account, CheckingAccount, ccount and Balance. Both the CheckingAccount and SavingsAccount classes will inherit from class Account, and they will both have a data member of type Balance. Within method main, which is within class MustangBanking, create an ArrayListof type Account. You may call this ArrayList accounts. Within a loop, display the messages "Welcome to your Mustang Bank!" and "Please choose from the following options These options will be 1 Create a new Checking Account 2-Create a new Savings Account 3 Delete an existing account 4 -View a specific account 5 View all accounts 6-Write a check through a specific Checking Account 7-Withdraw funds from a specific account 8 Deposit funds into an account 9-Exit Program Please enter your option below: For option 1, call the method xCreateChecking, sending accounts. Upon returning, print out a statement that the Checking Account has been created. For option 2, call the method xCreteSavings, sending accounts. Upon returning, print out a statement that the Savings Account has been created. For option 3, call the method xDeleteAccount, sending accounts. For option 4, call the method xViewSpecific, sending accounts. For option 5, call the method xViewAll, sending accounts. For option 6, call the method xWriteCheck, sending accounts. For option 7, call the method xWithdraw, sending accounts. For option 8, call the method xDeposit, sending accounts. option 9 should have the loop end and the program exit. Classes: The Account class will consist of ild (integer) dInterest Rate (double) bBalance (Balance)-Balance is a separate class With methods: Constructor Account, which takes in the Id, Interest Rate and Balance amounts.Explanation / Answer
public class Account {
private double balance;
protected int accno;
public int getAccno() {
return accno;
}
public void setAccno(int accno) {
this.accno = accno;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public Account(double balance, int accno) {
this.balance = balance;
this.accno = accno;
}
@Override
public String toString() {
return "Account [balance=" + balance + ", accno=" + accno + "]";
}
public double withdraw(double amount) {
return balance - amount;
}
public double deposit(double amount) {
return balance + amount;
}
}
public class CheckingAccount extends Account {
public CheckingAccount(double balance, int accno) {
super(balance, accno);
}
@Override
public String toString() {
return "CheckingAccount getAccno()=" + getAccno() + ", getBalance()="
+ getBalance();
}
}
public class SavingsAccount extends Account {
public SavingsAccount(double balance, int accno) {
super(balance, accno);
}
@Override
public String toString() {
return "SavingsAccount [getAccno()=" + getAccno() + ", getBalance()="
+ getBalance() + "]";
}
}
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
public class MustangBanking {
private static List<Account> list = new ArrayList<Account>();
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int i = 1;
while (i == 1) {
System.out.println("welcome to the mustang bank");
System.out.println("please choose the following opnions");
System.out.println("1 – Create a new Checking Account");
System.out.println("2 – Create a new Savings Account");
System.out.println("3 – Delete an existing account");
System.out.println("4 – View a specific account");
System.out.println("5 – View all accounts");
System.out
.println("6 – Write a check through a specific Checking Account");
System.out.println("7 – Withdraw funds from a specific account");
System.out.println("8 – Deposit funds into an account");
System.out.println("9 – Exit Program");
System.out.println("enter your choice");
int choice = scanner.nextInt();
switch (choice) {
case 1:
System.out
.println("please deposit initial balance to deposit to create cheking account");
double amount = scanner.nextDouble();
Random rand = new Random();
int accno = rand.nextInt(1000);
Account account = new CheckingAccount(amount, accno);
System.out.println("checking account created");
list.add(account);
break;
case 2:
System.out
.println("please deposit initial balance to deposit to create savings account");
double amount1 = scanner.nextDouble();
Random random = new Random();
int accno1 = random.nextInt(1000);
Account account1 = new SavingsAccount(amount1, accno1);
list.add(account1);
System.out.println("savings account created");
break;
case 3:
System.out
.println("enter accno to remove the account in the bank");
int removeaccno = scanner.nextInt();
int count = 0;
for (Account accs : list) {
if (removeaccno == accs.getAccno())
;
{
list.remove(accs);
count++;
}
}
System.out.println("");
if (count == 0) {
System.out.println("record not found to delete");
}
break;
case 5:
System.out.println("to view all accounts");
for (Account accoutn : list) {
System.out.println(accoutn);
}
break;
case 4:
System.out.println("enter the accno to view specific account");
int accountno = scanner.nextInt();
int count1 = 0;
for (Account accs : list) {
if (accountno == accs.getAccno()) {
System.out.println(accs);
count1++;
}
}
if (count1 == 0) {
System.out.println("account not found");
}
break;
case 6:
System.out.println("writing check");
System.out.println("enter account no");
int accountnumber = scanner.nextInt();
System.out.println("enter the amount in the check");
double checkAmount = scanner.nextDouble();
for (Account accs : list) {
if (accountnumber == accs.getAccno()) {
accs.withdraw(checkAmount);
}
}
System.out.println("the check withdraw amount is "
+ checkAmount);
break;
case 7:
int accountnumber1 = scanner.nextInt();
System.out.println("enter the amount to withdraw");
double checkAmount1 = scanner.nextDouble();
for (Account accs : list) {
if (accountnumber1 == accs.getAccno()) {
accs.withdraw(checkAmount1);
}
}
System.out.println("the withdraw amount is " + checkAmount1);
break;
case 8:
System.out.println("enter account no to deposit");
int accountnumber2 = scanner.nextInt();
System.out.println("enter the amount in the check");
double checkAmount2 = scanner.nextDouble();
for (Account accs : list) {
if (accountnumber2 == accs.getAccno()) {
accs.withdraw(checkAmount2);
}
}
System.out.println("the check withdraw amount is "
+ checkAmount2);
break;
case 9:
System.out.println("do you want to exit or not type y/n");
String exitChoice = scanner.next();
if ("y".equals(exitChoice)) {
System.exit(0);
} else
break;
default:
System.out.println("you choosen wrong choice");
break;
}
}
}
}
output
welcome to the mustang bank
please choose the following opnions
1 – Create a new Checking Account
2 – Create a new Savings Account
3 – Delete an existing account
4 – View a specific account
5 – View all accounts
6 – Write a check through a specific Checking Account
7 – Withdraw funds from a specific account
8 – Deposit funds into an account
9 – Exit Program
enter your choice
1
please deposit initial balance to deposit to create cheking account
2500
checking account created
welcome to the mustang bank
please choose the following opnions
1 – Create a new Checking Account
2 – Create a new Savings Account
3 – Delete an existing account
4 – View a specific account
5 – View all accounts
6 – Write a check through a specific Checking Account
7 – Withdraw funds from a specific account
8 – Deposit funds into an account
9 – Exit Program
enter your choice
2
please deposit initial balance to deposit to create savings account
8500
savings account created
welcome to the mustang bank
please choose the following opnions
1 – Create a new Checking Account
2 – Create a new Savings Account
3 – Delete an existing account
4 – View a specific account
5 – View all accounts
6 – Write a check through a specific Checking Account
7 – Withdraw funds from a specific account
8 – Deposit funds into an account
9 – Exit Program
enter your choice
5
to view all accounts
CheckingAccount getAccno()=544, getBalance()=2500.0
SavingsAccount [getAccno()=64, getBalance()=8500.0]
welcome to the mustang bank
please choose the following opnions
1 – Create a new Checking Account
2 – Create a new Savings Account
3 – Delete an existing account
4 – View a specific account
5 – View all accounts
6 – Write a check through a specific Checking Account
7 – Withdraw funds from a specific account
8 – Deposit funds into an account
9 – Exit Program
enter your choice
9
do you want to exit or not type y/n
y