subject

Fill in the code for method toString, which should return a string containing the name, account number, and balance for the account. Fill in the code for method chargeFee, which should deduct a service fee from the account.
Modify chargeFee so that instead of returning void, it returns the new balance. Note that you will have to make changes in two places.
Fill in the code for method changeName which takes a string as a parameter and changes the name on the account to be that string.

Modify ManageAccounts so that it prints the balance after the calls to chargeFees. Instead of using the getBalance method like you did after the deposit and withdrawal, use the balance that is returned from the chargeFees method. You can either store it in a variable and then print the value of the variable, or embed the method call in a println statement.

//
// 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
{
private double balance;
private String name;
private long acctNum;

//
//Constructor -- initializes balance, owner, and account number
//
public Account(double initBal, String owner, long number)
{
balance = initBal;
name = owner;
acctNum = number;
}

//
// 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("Insufficient funds");
}

//
// Adds deposit amount to balance.
//
public void deposit(double amount)
{
balance += amount;
}

//
// Returns balance.
//
public double getBalance()
{
return balance;
}

//
// Returns a string containing the name, account number, and balance.
//
public String toString()
{

}

//
// Deducts $10 service fee
//
public void chargeFee()
{

}

//
// Changes the name on the account
//
public void changeName(String newName)

{

}

}

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

//create account1 for Sally with $1000
acct1 = new Account(1000, "Sally", 1111);

//create account2 for Joe with $500

//deposit $100 to Joe's account

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

//withdraw $50 from Sally's account

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

//charge fees to both accounts

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

//print summary for both accounts

}
}

ansver
Answers: 1

Another question on Advanced Placement (AP)

question
Advanced Placement (AP), 23.06.2019 20:00
The sun a. will become a red giant within two to three million years b. is in its main sequence, which willlast thousands of years c. is in its main sequence, which will last billions of years. d. will explode as a supernova after its main sequence
Answers: 1
question
Advanced Placement (AP), 25.06.2019 13:30
Arandom variable x has a mean of 10 and a standard deviation of 3. if each value of x is multiplied by 2, what will the new mean and standard deviation be?
Answers: 1
question
Advanced Placement (AP), 25.06.2019 22:00
When your organs don't receive enough blood, they begin to a. shut down b. speed up c. inflame d. dry out
Answers: 2
question
Advanced Placement (AP), 26.06.2019 12:00
20 pts i don't really get this xd1. what is the function in humans of the protein produced from that gene2. would you expect to find the same protein in other organisms? if so, which ones? 3. is it possible to find the same gene in two diff. kinds of organisms4. if you found the same gene in all organisms you test, what does this esuggest about the evolution of this gene in the history of life on earth? 5. does the use of dna sequences in the study of evolutionary relationships mean that other characteristics are unimportant in such studies? explain your answer. what am i supposed to do here
Answers: 1
You know the right answer?
Fill in the code for method toString, which should return a string containing the name, account numb...
Questions
question
Social Studies, 02.06.2021 16:50
Questions on the website: 13722360