I\'d appreciate it if someone could help me out on Part B. The program is in Jav
ID: 3909140 • Letter: I
Question
I'd appreciate it if someone could help me out on Part B. The program is in Java and I Just want to make sure that I know what part B should look like.
Part A- BankAccount Class (70 points) Write a class to describe a BankAccount object. A bank account is described by the account owner's name . an account ID (stored as text) the balance in the account In your class, include: instance data variables a constructor getters and setters (with appropriate value checks, when applicable) a toString method (you can decide the output) . a deposit method (with appropriate value checks; output an error message to the user when appropriate) a withdraw method (with appropriate value checks, output an error message to the user when appropriate) Part B- Driver Program (30 points) Write an interactive driver program for the user to create and modify bank account objects. The user first creates a bank account with an initial balance The user can then repeatedly make a deposit, a withdrawal, check the balance, or quit Extra Credit (10 points) Include a monthly fee as part of what describes a bank account. Update the BankAccount class as necessary The user should be able to set the fee amount associated with each account and apply the fee through a method Add code to the driver program to demonstrate the fee functionalityExplanation / Answer
Given below is the code for the question.
To indent code in eclipse , select code by pressing ctrl+a and then indent using ctrl+i
Please do rate the answer if it was helpful. Thank you
BankAccount.java
=======
public class BankAccount {
private String owner;
private String ID;
private double balance;
public BankAccount(){
owner = "";
ID = "";
balance = 0;
}
public BankAccount(String owner, String ID, double balance){
this.owner = owner;
this.ID = ID;
this.balance = balance;
}
public void deposit(double amt){
if(amt <= 0)
System.out.println("Should deposit a positive amount");
else
balance += amt;
}
public void withdraw(double amt){
if(amt <= 0)
System.out.println("Withdrawal amount should be a positive value");
else if(amt > balance)
System.out.println("Withdrawal amount of " + amt + " is more than available balance " + balance);
else
balance -= amt;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getID() {
return ID;
}
public void setID(String iD) {
ID = iD;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
}
BankAccountDriver.java
-----------
import java.util.Scanner;
public class BankAccountDriver {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String owner, ID;
double balance;
BankAccount acc = new BankAccount();
System.out.print("Enter owner name: ");
owner = keyboard.nextLine();
System.out.print("Enter accound ID: ");
ID = keyboard.next();
System.out.print("Enter initial balance: ");
balance = keyboard.nextDouble();
acc.setOwner(owner);
acc.setID(ID);
acc.setBalance(balance);
int choice = 0;
double amt;
while(choice != 4){
System.out.println("1. Deposit");
System.out.println("2. Withdraw");
System.out.println("3. Check balance");
System.out.println("4. Quit");
System.out.print("Enter your choice: ");
choice = keyboard.nextInt();
switch(choice){
case 1:
System.out.print("Enter deposit amount: ");
amt = keyboard.nextDouble();
acc.deposit(amt);
break;
case 2:
System.out.print("Enter withdrawal amount: ");
amt = keyboard.nextDouble();
acc.withdraw(amt);
break;
case 3:
System.out.printf("Balance: %.2f ", acc.getBalance() );
break;
case 4:
break;
default:
System.out.println("Invalid menu choice!");
}
System.out.println();
}
}
}
output
-----
Enter owner name: John Smith
Enter accound ID: 1111
Enter initial balance: 1000
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 3
Balance: 1000.00
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 1
Enter deposit amount: 200
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 3
Balance: 1200.00
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 1
Enter deposit amount: -500
Should deposit a positive amount
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 1
Enter deposit amount: 150
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 3
Balance: 1350.00
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 2
Enter withdrawal amount: -19
Withdrawal amount should be a positive value
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 2
Enter withdrawal amount: 2000
Withdrawal amount of 2000.0 is more than available balance 1350.0
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 2
Enter withdrawal amount: 500
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 3
Balance: 850.00
1. Deposit
2. Withdraw
3. Check balance
4. Quit
Enter your choice: 4
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.