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

File Account.java contains a partial denition for a class representing a bank ac

ID: 3539156 • Letter: F

Question

File Account.java contains a partial denition for a class representing a bank account. ManageAccounts.java is a test harness for the Account class. Save them to your directory. (Both les must be in the same directory.) Examine Account.java to see which methods it contains. Then complete the following tasks. Remember to compile and run ManageAccounts.java after each task, making sure the code works. (Compiling ManageAccounts.java will automatically compile Account.java.) 1. Complete the ManageAccounts class according to the comments. (Once account2 is created, uncomment the last line.) 2. Implement the Account.chargeFee() method. This method should reduce the account's balance by $10. 3. Modify the Account.chargeFee() method to return the new balance (instead of void). 4. Modify ManageAccounts to print the balance of each account after charging the fee. (Do not use getBalance() for this; use the balance returned from Account.chargeFee(). 5. Implement the Account.changeName() method. Submit Account.java and ManageAccounts.java. Sample Output Sally's new balance: 950.0 Joe's new balance: 600.0 After fee, Sally's account balance: 940.0 After fee, Joe's account balance: 590.0 Sally's account: 1111 Sally $940.00 Joe's account: 2222 Joseph $590.0 // **************************************************************** // 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 account1, account2; //create account1 for Sally with $1000 account1 = new Account(1000, "Sally", 1111); //create account2 for Joe with $500 //withdraw $50 from Sally's account account1.withdraw(50); //print Sally's new balance (use getBalance()) //deposit $100 to Joe's account //print Joe's new balance (use getBalance()) //charge fees to both accounts //change the name on Joe's account to Joseph //print summary for both accounts System.out.println("Sally's account: " + account1); //System.out.println("Joe's account: " + account2); } } //******************************************************* // 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. //******************************************************* import java.text.NumberFormat; 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() { NumberFormat fmt = NumberFormat.getCurrencyInstance(); return (acctNum + " " + name +" " + fmt.format(balance)); } //---------------------------------------------- // Deducts $10 service fee //---------------------------------------------- public void chargeFee() { } //---------------------------------------------- // Changes the name on the account //---------------------------------------------- public void changeName(String newName) { } } Critter Caretaker The Critter class is a virtual pet, which a user can interact with in various ways: the user can feed the critter, play with the critter, and listen to the critter. CritterCaretaker.java is a driver program that uses the Critter class. The only changes you should make to this program are to uncomment relevant sections of the code. The Critter class is partially implemented; your task is to complete it. To do so: 1. Complete the Critter.getHunger() method, which should return the critter's hunger level as an int. 2. Complete the Critter.eat() method, which should reduce the critter's hunger level by 3, with a minimum level of 0. 3. Complete the Critter.play() method, which should reduce the critter's boredom level by 3, with a minimum level of 0. 4. Complete the Critter.talk() method, which should print a message corresponding to the critter's mood: mood > 15 mad 10 < mood 15 frustrated 5 < mood 10 ok mood 5 happy Submit Critter.java. (CritterCaretaker.java will be ignored.) // **************************************************************** // CritterCaretaker.java // // Takes care of the Critter by giving the player options of listening, // feeding, or playing with the critter. // **************************************************************** import java.util.Scanner; public class CritterCaretaker{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); Critter crit = new Critter(); crit.greet(); int choice; do { System.out.println("Critter Caretaker "); System.out.println("0 - Quit"); System.out.println("1 - Listen to your critter"); System.out.println("2 - Feed your critter"); System.out.println("3 - Play with your critter"); System.out.println("Enter your choice"); choice = scan.nextInt(); switch(choice) { case 0: System.out.println("Good bye."); break; case 1: // Uncomment this after completing task 4. //crit.talk(); crit.passTime(); break; case 2: // Uncomment this after completing task 2. //crit.eat(); crit.passTime(); break; case 3: // Uncomment this after completing task 3. //crit.play(); crit.passTime(); break; default: System.out.println("Sorry, the choice you made " + choice + " is not a valid choice."); } // Uncomment this line after completing task 1. //System.out.println("My hunger level is " + crit.getHunger() + " and my boredom level is " + crit.getBoredom() + "."); }while(choice!=0); } } // **************************************************************** // Critter.java // // Define a Critter class. // **************************************************************** public class Critter { //declare instance data private int hunger = 0; private int boredom = 0; //----------------------------------------------- //constructor //----------------------------------------------- public Critter() { System.out.println("A new critter has been born!"); } //----------------------------------------------- //greet: print a greeting message with the hunger level and // the boredom level. //----------------------------------------------- public void greet() { System.out.println("Hi, I'm a critter. My hunger level is " + hunger + " and my boredom level is " + boredom + "."); } //----------------------------------------------- //getBoredom: return the boredom level //----------------------------------------------- public int getBoredom() { return boredom; } //----------------------------------------------- //getHunger: return the hunger level //----------------------------------------------- //add header for getHunger { //add body of getHunger } //----------------------------------------------- //getMood: return the mood as the addition of hunger // level and the boredom level //----------------------------------------------- public int getMood() { return hunger + boredom; } //----------------------------------------------- //passTime: increase the hunger level and the boredom // level by 1 //----------------------------------------------- public void passTime() { hunger++; boredom++; } //----------------------------------------------- //eat: decrease the hunger level by 3 and set it to 0 if // it is less than 0 //----------------------------------------------- public void eat() { System.out.println("Brruppp"); // add your code here } //----------------------------------------------- //play: decrease the boredom level by 3 and set it to 0 if // it is less than 0 //----------------------------------------------- //add header for play { //add body of play } //----------------------------------------------- // talk: print how the critter feel, which can be mad (if mood > 15), // frustrated (if mood > 10 and mood <= 15), ok (if mood > 5 and mood // <= 10), or happy (if mood <= 5). //----------------------------------------------- public void talk() { System.out.print("I feel "); int mood = getMood(); // add your code here } } First one to get a working program gets 5 stars, been working on this for more than 10 hours and can't figure it out, sorry I might sound stupid but it's true, Im brand new to programming.

Explanation / Answer

Hey,, I can help you this assignment. If you could just add me on

S K Y P E , i DON'T need CHEGG POINTS AND RATING

my id is adiboi-10

Thanks mate

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