Question: Help with create below feature in bold, please answer with code example and show wich class the code shall be inserted in, Thanks! -Unique social

Help with create below feature in bold, please answer with code example and show wich class the code shall be inserted in, Thanks!

-Unique social security numbers, if a customer already has that social security number, a new customer should not be created.

Help with create below feature in bold, please answer with code example

and show wich class the code shall be inserted in, Thanks! -Unique

social security numbers, if a customer already has that social security number,

a new customer should not be created. import java.util.*; public class BankLogic{ List customers = new ArrayList(); int numberOfCustomers; = public BankLogic() {

numberOfCustomers = 0; } public void addCustomer(Customer customer) { customers.add(customer); numberOfCustomers +=1;

} public void removeCustomer(int ssn) { for (int i = 0; i

import java.util.*; public class BankLogic { List customers = new ArrayList(); int numberOfCustomers; = public BankLogic() { numberOfCustomers = 0; } public void addCustomer(Customer customer) { customers.add(customer); numberOfCustomers +=1; } public void removeCustomer(int ssn) { for (int i = 0; i accounts = customers.get(i).getAccounts(); for(SavingsAccount account: accounts) { account.close(customers.get(i).getName()); } customers.remove(customers.get(i)); } } numberOfCustomers -= 1; } public List getCustomers() { return customers; } public void setCustomers (List newCustomers) { customers = newCustomers; } } -import java.util.ArrayList; import java.util.List; public class Customer List accounts = new ArrayList(); int numberOfAccount; int ssn; String name; static int uniqueSSN = 1001; public Customer { accounts = new ArrayList(); numberOfAccount = 0; ssn = uniqueSSN++; } public Customer(int ssn, String name) { numberOfAccount =0; this.ssn = ssn; this.name = name; } public int getSSN() { return ssn; } public String getName() { return name; } public void setName(String n) { this.name =n; } public List getAccounts() { return accounts; } public void createAccount(float rate, float amount) SavingsAccount account = new SavingsAccount(rate, amount); accounts.add(account); numberOfAccount += 1; } public void displayAccount() { for (SavingsAccount account:accounts) { account.print(this.getName()); public class CustomerBuilder { private int ssn; private String name; public CustomerBuilder setssn(int ssn) { this.ssn = ssn; return this; } public CustomerBuilder setName(String name) { this.name = name; return this; } public Customer createCustomer() { return new Customer (ssn, name); } import java.util.*; import java.util.HashSet; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Bank Logic Bank = new Bank Logic(); System.out.println(" Welcome to the Bank"); System.out.println("*******************"); boolean doneWithBanking = false; while(!doneWithBanking) { System.out.println(" Add a new Customer 1"); System.out.println("Delete a customer 2"); System.out.println("Create an account for existing customer 3"); System.out.println("See information for a customer 4"); System.out.println("Deposit 5"); System.out.println("Withdraw 6"); System.out.println("Edit a customer name 7"); System.out.println("Quit 0"); System.out.print(" Enter your choice: "); int choice = sc.nextInt(); int ssn; HashSet hashSet = new HashSet(); switch (choice) { case 1: { while(true) { System.out.print("Enter customer unique ssn: "); ssn = sc.nextInt(); if (hashSet.contains(ssn)) { System.out.println("Ssn already exist"); continue; } else break; } hashSet.add(ssn); System.out.print("Enter customer name: "); sc.nextLine(); String name = sc.nextLine(); L/sc.nextLine(); //Customer customer = new Customer(ssn, name); Customer customer = new CustomerBuilder().setSsn(ssn).setName(name).createCustomer(); Bank.addCustomer (customer); System.out.println(" Customer added successfully with uniquely ssn: " + customer.getSSN()); } break; case 2: { System.out.print("Enter ssn: "); ssn = sc.nextInt(); Bank.removeCustomer(ssn); } break; case 3: { System.out.print("Enter ssn: "); ssn = sc.nextInt(); List customers = Bank.getCustomers(); for (Customer c:customers) { if(c.getSSN() == ssn) { c.displayAccount(); } } } break; case 5: { System.out.print("Enter ssn: "); ssn = sc.nextInt(); System.out.print("SSN: "+ssn); List customers = Bank.getCustomers(); for(Customer c:customers) { if(c.getSSN() == ssn) { List accounts = c.getAccounts(); System.out.print(" Enter account number to deposit: "); int accno = sc.nextInt(); System.out.print("Enter deposited amount: "); float amount = sc.nextFloat(); for(SavingsAccount a:accounts) { if(a.getAccountNumber() ==accno) { a.deposit(amount); } break; case 6: { System.out.print("Enter ssn: "); ssn = sc.nextInt(); System.out.print("SSN: "+Ssn); List customers = Bank.getCustomers(); for (Customer c:customers) { if(c.getSSN() == ssn) { List accounts = c.getAccounts(); System.out.print(" Enter account number to withdraw:"); int accno = sc.nextInt(); System.out.print("Enter withdraw amount: "); float amount = sc.nextFloat(); for (SavingsAccount a:accounts) { if(a.getAccountNumber()==accno) { a.withdraw(amount); } break; case 7: { System.out.print("Enter customer ssn: "); ssn = sc.nextInt(); System.out.print("Enter modified customer name: "); sc.nextLine(); String cname = sc.nextLine(); List cust = Bank.getCustomers(); for (Customer c:cust) { if(c.getSSN() == ssn) { c.setName(cname); } } Bank.setCustomers(cust); System.out.print(" Customer name updated successfully with ssn: "+Ssn); } break; case 0: { doneWithBanking = true; } break; default: System.out.println("Invalid option"); break; public class SavingsAccount { float rate = 1; float balance; boolean closed = false; public Savings Account(boolean closed) { this.closed = closed; } int account Number; static int GetAccount Number=1001; String accountType = "Savings"; public SavingsAccount(float rt, float balance) rate = rt; this.balance = balance; account Number = GetAccount Number++; } public void close(String name) { closed = true; System.out.println("Account closed"); System.out.println("Account number: + account Number); System.out.println("Account holder Name: "+name); System.out.println("Balance: " + balance); System.out.println("Account type: " + accountType); System.out.println("With interest 1,2 %:"); System.out.println("Interest amount: " + 0.012f * balance); } public void print(String name) System.out.println("Account number: " + account Number); System.out.println("Account holder name: " + name); System.out.println("Balance: " + balance); System.out.println("Account type: "+accountType); System.out.println("Interest rate: "+rate); } public int getAccount Number() { return account Number; } public String getAccountType() { return accountType; } public void deposit(float amount) balance += amount; } public float withdraw(float amount) { if (amount > balance) { System.out.println(" Insufficient balance!"); return 0; } return balance -= amount

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!