Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please meet all the requirements based on the instructions and get the same outp

ID: 3732488 • Letter: P

Question

Please meet all the requirements based on the instructions and get the same outputs as are shown in the screenshot. THANKS!!

HW7 (Graded out of 100) Design a bank account class named Account that has the following private member variables: accountNumber of type int numOwners of type int // number of account co-owners (account can have more than one owner) ownerPtr of type Person //, ownerPtr points to an array of Person, where Person is a structure. The Person structure is defined below accountCounter of type static int // initialized at 1000, incremented at each account creation, used to automate account number assignment

Explanation / Answer

class BankAccount {

Scanner input = new Scanner(System.in);

static String name, actype;

static int bal, amt;

Random randomGenerator = new Random();

int accNo = randomGenerator.nextInt(100);

public void createAccount(String name, int accNo, String actype, int bal) {

this.name = name;

this.accNo = accNo;

this.actype = actype;

this.bal = bal;

}

public int deposit() {

System.out.print("Enter depost amount:");

amount = input.nextInt();

if (amount < 0) {

System.out.println("Invalid");

return 1;

}

Bal = Bal + amt;

return 0;

}

int withdraw() {

if (Bal < amt) {

System.out.println("Not enough funds.");

return 1;

}

if (amt < 0) {

System.out.println("Invalid");

return 1;

}

Bal = Bal - amt;

return 0;

}

void display() {

System.out.println("Name:" + name);

System.out.println("Account No:" + accNo);

System.out.println("Balance:" + bal);

}

void dbal() {

System.out.println("Balance:" + bal);

}

}

  

public class Client {

public static void main(String args[]) {

Scanner input = new Scanner(System.in);

  

BankAccount b1 = new BankAccount();

int menu;

System.out.println("Menu");

System.out.println("1. Create account");

System.out.println("2. Deposit Amount");

System.out.println("3. Withdraw Amount");

System.out.println("4. Display Information");

System.out.println("5. Exit");

boolean quit = false;

do {

System.out.print("Please enter your choice: ");

menu = input.nextInt();

switch (menu) {

case 1:

System.out.println("Enter your Name: ");

String cusName = input.nextLine();

System.out.println("Enter Account Type: ");

String type = input.next();

System.out.println("Enter Initial Balance: ");

int bal = input.nextInt();

b1.createAccount(cusName,num,type,bal);

case 2:

b1.deposit();

break;

case 3:

b1.withdraw();

System.out.println("Current Account Balance=" + Balance);

System.out.print("Enter withdrawal amount:");

amount = input.nextInt();

break;

case 4:

b1.display();

break;

case 5:

quit = true;

break;

}

} while (!quit);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote