Question: I have the following two JAVA programs. I have completed the Account.java program but need help finishing the ManageAccounts.java one. //******************************************************* // Account.java // //

I have the following two JAVA programs. I have completed the Account.java program but need help finishing the ManageAccounts.java one.

//*******************************************************

// Account.java

//

// A bank account class with methods to deposit to, withdraw from,

// change the name on, charge a fee to, and print a summary of the account.

//*******************************************************

public class Account

{

//step1: the class has the fields:the account balance, the name of the account holder, and an account number.

private double balance;

private String name;

private int accNumber;

//----------------------------------------------

//step2: Constructor -- initializes balance, owner, and account number

//----------------------------------------------

public Account(double b, String n, int a){

balance = b;

name = n;

accNumber = a;}

//----------------------------------------------

//step2: Overload the constructor -- initializes owner and account number, and set balance to 0

//----------------------------------------------

public Account(String n, int a){

balance = 0;

name = n;

accNumber = a;

}

//----------------------------------------------

// step3: withdraw method. It checks to see if balance is sufficient for withdrawal.

// If so, decrements balance by amount; if not, prints message.

//----------------------------------------------

public void withdraw(double amount){

if(balance>amount)

balance-=amount;

else

System.out.println("Balance is insufficient for withdrawa;.");}

//----------------------------------------------

//step4: deposit method: adds deposit amount to balance.

//----------------------------------------------

public void deposit(double d){

balance = balance +d;}

//----------------------------------------------

//step5: Write mutator and accessor methods for balance. Two methods are needed

//----------------------------------------------

public void setBalance(double balance){

this.balance=balance;}

public double getBalance(){

return balance;}

//----------------------------------------------

//step6: Write mutator and accessor methods for name. Two methods are needed

//----------------------------------------------

public void setName(String name){

this.name=name;}

public String getName(){

return name;}

//----------------------------------------------

//step7: chargeFee method has no parameter, it deducts $10 service fee, and return nothing

//----------------------------------------------

public void chargefee(){

balance = balance - 10;}

}

// ****************************************************************

// ManageAccounts.java

//

// Use Account class to create and manage Sally and Joe's

// bank accounts

// ****************************************************************

public class ManageAccounts

{

public static void main(String[] args)

{

Account acct1, acct2;

//step1: create account1 for Sally with account no, 100089, and initial balance, $1000

acct1= new Account(1000.0,"Sally", 100089);

//step2: create account2 for Joe with account no, 107060, and initial balance, $500

acct2= new Account(500.0,"Joe", 107060);

//step3: deposit $100 to Joe's account

acct2.deposit(100.0);

//step4: print Joe's new balance (use getBalance())

//step5: withdraw $50 from Sally's account

acct1.withdraw(50.0);

//step6: print Sally's new balance (use getBalance())

//step7: charge fees to Joe's accounts

//step8: charge fees to Sally's account

//step9: change the name on Joe's account to Joseph

//step10: print name and balance for Joe's accounts

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!