Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the current displayed customer PLEASEEEEEEEEEE package bankexample; import java.util.UUID; public

NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE)

Display the accounts for the current displayed customer PLEASEEEEEEEEEE

package bankexample;

import java.util.UUID;

public class Customer { private UUID id; private String email; private String password; private String firstName; private String lastName; public Customer(String firstName, String lastName, String email, String password) { this.id = UUID.randomUUID(); this.firstName = firstName; this.lastName = lastName; this.email = email; this.password = password; }

public String getFirstName() { return firstName; }

public void setFirstName(String firstName) { this.firstName = firstName; }

public String getLastName() { return lastName; }

public void setLastName(String lastName) { this.lastName = lastName; }

public String getEmail() { return email; }

public void setEmail(String email) { this.email = email; }

public String getPassword() { return password; }

public void setPassword(String password) { this.password = password; } @Override public String toString() { return this.firstName + " " + this.lastName; } }

package bankexample;

public class Vault { private Double cash; public Vault() {

this.cash = 0.0; } public Double getCash() { return cash; } public void addCash(Double cash) { if(cash > 0) { this.cash += cash; } } public Boolean removeCash(Double cash) { Boolean success = false; if(this.cash >= cash) { this.cash -= cash; success = true; } return success; } }package bankexample;

import java.util.UUID;

public class Account {

private final UUID id; private Double balance; private Double interestRate; private AccountType accountType; private Customer customer; public static void main(String[] args) { Bank bankExample = new Bank(); bankExample.start(); bankExample.outputAllCustomers();

int n = bankExample.getNumCustomers();

if(n > 0 ) {

Customer c1 = bankExample.getCustomer(0); System.out.println(c1.getFirstName() + " " + c1.getLastName()); }

n = bankExample.getNumAccounts(); if(n > 0) { Account acc1 = bankExample.getAccount(0); Account acc2 = bankExample.getAccount(1); System.out.println(acc1.getType().toString() + " : " + acc1.getBalance()); System.out.println(acc2.getType().toString() + " : " + acc2.getBalance()); }

} public Account(AccountType accountType, Double interestRate) { this.balance = 0.0; this.interestRate = interestRate; this.accountType = accountType; this.id = UUID.randomUUID(); } public double getBalance() { return balance; }

public UUID getId() { return id; }

public double getInterestRate() { return interestRate; }

public void setInterestRate(double interestRate) { this.interestRate = interestRate; }

public Customer getCustomer() { return customer; }

public void setCustomer(Customer customer) { this.customer = customer; } public void deposit(double cash) { if(cash > 0) { this.balance += cash; } } public Boolean withdraw(double cash) { Boolean success = false; if(this.balance >= cash && cash > 0 ) { this.balance -= cash; success = true; } return success; } public void calculateInterest() { this.balance += this.balance * this.interestRate; } @Override public String toString() { return this.id + " | " + this.balance + " balance"; }

private Object getType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }

package bankexample;

import java.util.Scanner; import java.util.UUID;

public class BankExample {

private UUID id; private double balance; private double interestRate; Scanner keyboard = new Scanner(System.in); public BankExample() { balance = 0; } public double getCash() { return balance; } public UUID getID() { return id; }

public double getInterestRate() { return interestRate; } public void setInterestRate(double interestRate) {

this.interestRate = interestRate; } public void deposit(double cash) { if (cash > 0) { this.balance += cash; } } public boolean withdraw(double cash) { Boolean success = false; if(this.balance >= cash && cash > 0) { this.balance -= cash; success = true; } return success; } public void calculateInterest() { this.balance += this.balance * (this.interestRate); } }

package bankexample;

public class Bank { public final static Integer MAX_ACCOUNTS = 2; public final static Integer MAX_CUSTOMERS = 10; private final static Double INTEREST_RATE = 0.02; private final static Double INITIAL_DEPOSIT = 500.00; private final static Integer WITHDRAW_COUNT = 4; private Customer[] customers; private Account[] accounts; private Vault vault; private Integer customerIndex; public Bank() { this.accounts = new Account[MAX_CUSTOMERS * MAX_ACCOUNTS]; this.customers = new Customer[MAX_CUSTOMERS]; this.vault = new Vault(); this.customerIndex = 0; } public void start() { createAllCustomers(); createAccountsForAllCustomers(); depositMoneyToAllAccounts(); withdrawMoneyFromRandomAccounts(); } public Customer getFirstCustomer() { return this.customers[0]; } private void createAccountsForAllCustomers() { for(int i = 0; i < this.customers.length; i++) { for(int k = 0; k < MAX_ACCOUNTS; k++) { Account account = createAccount(this.customers[i]); this.accounts[MAX_ACCOUNTS * i + k] = account; } } } private Account createAccount(Customer customer) { Account account = new Account( AccountType.Checking, INTEREST_RATE ); account.setCustomer(customer); return account; } private void createAllCustomers() { for(int i = 0; i < this.customers.length; i++) { Customer customer = new Customer( "FN " + i, "LN " + i, "FN_LN " + i + "@website", "password" ); this.customers[i] = customer; } } private void depositMoneyToAllAccounts() { for(int i = 0; i < this.accounts.length; i++) { Account account = this.accounts[i]; account.deposit(INITIAL_DEPOSIT); vault.addCash(INITIAL_DEPOSIT); } } public void outputAllCustomers() { for(int i = 0; i < this.customers.length; i++) { System.out.println(this.customers[i]); } } public void outputAllAccounts() { for (Account account : this.accounts) { System.out.println(account); } }

private void withdrawMoneyFromRandomAccounts() {

int start = 0; int end = this.accounts.length; for(int i = 0; i < WITHDRAW_COUNT; i++) { int accountIndex = Utilities.getRandomNumber(start, end); Account account = this.accounts[accountIndex]; withdrawMoneyFromAccount(account); } } private void withdrawMoneyFromAccount(Account account) { Integer amount = Utilities.getRandomNumber(1, (int)account.getBalance()); account.withdraw(amount); this.vault.removeCash((double)amount); }

public Customer getNextCustomer() {

if(customerIndex < this.customers.length - 1) { customerIndex++; } return this.customers[customerIndex]; }

public Customer getPreviousCustomer() { if(customerIndex > 0) { customerIndex--; } return this.customers[customerIndex]; } } package bankexample;

public enum AccountType {

Savings,

Checking,

CreditCard }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions

Question

Design a job advertisement.

Answered: 1 week ago