Question

NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the...

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
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

output:

FN 0 LN 0
FN 1 LN 1
FN 2 LN 2
FN 3 LN 3
FN 4 LN 4
FN 5 LN 5
FN 6 LN 6
FN 7 LN 7
FN 8 LN 8
FN 9 LN 9
FN 0 LN 0

Code :

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bankexample;

/**
*
* @author Gajendra
*/
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;
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];
}

public int getNumCustomers(){
return this.customers.length;
}
public Customer getCustomer(int index) {
return this.customers[index];
}
public int getNumAccounts(){
return this.accounts.length;
}

public Account getAccount(int index) {
return this.accounts[index];
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bankexample;

/**
*
* @author Gajendra
*/
public enum AccountType {
Savings,

Checking,

CreditCard
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bankexample;

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

/**
*
* @author Gajendra
*/
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);
}
  
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bankexample;

import java.util.UUID;

/**
*
* @author Gajendra
*/
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;
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bankexample;

/**
*
* @author Gajendra
*/
public class Utilities {
public static int getRandomNumber(int min, int max){
int x = (int) ((Math.random()*((max-min)+1))+min);
return x;
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bankexample;

/**
*
* @author Gajendra
*/
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;
}
}

Add a comment
Know the answer?
Add Answer to:
NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (Reading & Writing Business Objects) I need to have my Classes be able to talk to...

    (Reading & Writing Business Objects) I need to have my Classes be able to talk to Files. How do I make it such that I can look in a File for an account number and I am able to pull up all the details? The file should be delimited by colons (":"). The Code for testing 'Select' that goes in main is: Account a1 = new Account(); a1.select(“90001”); a1.display(); Below is what it should look like for accounts 90000:3003:SAV:8855.90 &...

  • I have a little problem about my code. when i'm working on "toString method" in "Course"...

    I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student {    private String firstName;    private String lastName;    private String id;    private boolean tuitionPaid;       public Student(String firstName, String lastName, String id, boolean tuitionPaid)    {        this.firstName=firstName;        this.lastName=lastName;        this.id=id;        this.tuitionPaid=tuitionPaid;    }   ...

  • I need help in getting the second output to show both the commission rate and the...

    I need help in getting the second output to show both the commission rate and the earnings for the String method output package CompemsationTypes; public class BasePlusCommissionEmployee extends CommissionEmployee { public void setGrossSales(double grossSales) { super.setGrossSales(grossSales); } public double getGrossSales() { return super.getGrossSales(); } public void setCommissionRate(double commissionRate) { super.setCommissionRate(commissionRate); } public double getCommissionRate() { return super.getCommissionRate(); } public String getFirstName() { return super.getFirstName(); } public String getLastName() { return super.getLastName(); } public String getSocialSecurityNumber() { return super.getSocialSecurityNumber(); } private...

  • Requirements:  Your Java class names must follow the names specified above. Note that they are...

    Requirements:  Your Java class names must follow the names specified above. Note that they are case sensitive. See our template below.  BankAccount: an abstract class.  SavingAccount: a concrete class that extends BankAccount. o The constructor takes client's firstname, lastname and social security number. o The constructor should generate a random 6-digit number as the user account number. o The initial balance is 0 and the annual interest rate is fixed at 1.0% (0.01).o The withdraw method signature...

  • FOR JAVA: Summary: Create a program that adds students to the class list (see below). The...

    FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...

  • How to create a constructor that uses parameters from different classes? I have to create a...

    How to create a constructor that uses parameters from different classes? I have to create a constructor for the PrefferedCustomer class that takes parameters(name, address,phone number, customer id, mailing list status, purchase amount) but these parameters are in superclasses Person and Customer. I have to create an object like the example below....... PreferredCustomer preferredcustomer1 = new PreferredCustomer("John Adams", "Los Angeles, CA", "3235331234", 933, true, 400); System.out.println(preferredcustomer1.toString() + "\n"); public class Person { private String name; private String address; private long...

  • Here is the code from the previous three steps: #include <iostream> using namespace std; class Student...

    Here is the code from the previous three steps: #include <iostream> using namespace std; class Student { private: //class variables int ID; string firstName,lastName; public: Student(int ID,string firstName,string lastName) //constructor { this->ID=ID; this->firstName=firstName; this->lastName=lastName; } int getID() //getter method { return ID; } virtual string getType() = 0; //pure virtual function virtual void printInfo() //virtual function to print basic details of a student { cout << "Student type: " << getType() << endl; cout << "Student ID: " << ID...

  • HOW TO FiX EXCEPTIONS??? In order to populate the array, you will need to split() each...

    HOW TO FiX EXCEPTIONS??? In order to populate the array, you will need to split() each String on the (,) character so you can access each individual value of data. Based on the first value (e.g., #) your method will know whether to create a new Manager, HourlyWorker, or CommissionWorker object. Once created, populate the object with the remaining values then store it in the array. Finally, iterate through the array of employees using the enhanced for loop syntax, and...

  • Use the Java codes below (Checking Account and Checking Account Demo), and work on these problems....

    Use the Java codes below (Checking Account and Checking Account Demo), and work on these problems. You have to do both of your java codes based on the two provided Java codes. Create one method for depositing and one for withdrawing. The deposit method should have one parameter to indicate the amount to be deposited. You must make sure the amount to be deposited is positive. The withdraw method should have one parameter to indicate the amount to be withdrawn...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT