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

Hi, Everyone! I have a Java programming exam next week. Our professor gave us so

ID: 3551821 • Letter: H

Question

Hi, Everyone! I have a Java programming exam next week. Our professor gave us some study problems which we were told will be quite similar to the actual exam's. I got to the following problem and I'm not sure if I'm doing it right. Answers weren't provided with the study guide :(

If someone could give the correct pseudocode, I would really appreciate it! Also, feel free to comment on lines that might be more difficult to understand by a beginning programmer. I'd like to learn from it and actually apply the new knowledge I will gain on my exam next week!




Explanation / Answer

client class

public class Client {

public static void main(String args[]) {

Scanner input = new Scanner(System.in);   

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();

BankAccount b1 = new BankAccount(cusName, num, type, bal);

int menu;

System.out.println("Menu");

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

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

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

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

boolean quit = false;

do {

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

menu = input.nextInt();

switch (menu) {

case 1:

b1.deposit();

break;


case 2:

b1.withdraw();

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

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

amount = input.nextInt();

break;


case 3:

b1.display();

break;


case 4:

quit = true;

break;

}

} while (!quit);

}

}


money class



public class Money

{


static int accountNumber, Balance, amount;

Scanner input = new Scanner(System.in);

static String name, actype;

public int deposit() {

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

amount = input.nextInt();

if (amount < 0) {

System.out.println("Invalid");

return 1;

}

Balance = Balance + amount;

return 0;

}


int withdraw() {


if (Balance < amount) {

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

return 1;

}

if (amount < 0) {

System.out.println("Invalid");

return 1;

}

Balance = Balance - amount;

return 0;

}


}



BankAccount Class



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);


BankAccount(String name, int accNo, String actype, int bal) {

this.name = name;

this.accNo = accNo;

this.actype = actype;

this.bal = bal;

}

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);

}

}

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