Question: Java, plz!!!!!!!!!!!!!!!! Java !!!!! plz Bank Class (settter methods) You have a class called Bank that keeps track of how much money you have in
Java, plz!!!!!!!!!!!!!!!!


Java !!!!! plz
Bank Class (settter methods)
You have a class called Bank that keeps track of how much money you have in your "Bank account". You are provided with the constructor and the accessors, but you need to write the setter methods for this class. Write a method called addMoney to add money to the "spending account" (this is your spendings variable), and another method that "transfers" all of your money from your spending account into your savings account (this is your savings variable). E.g. 1: If I had a Bank object called myBank, myBank.addMoney(150.0) should add $150 to my spending account E.g. 2: If I had a Bank object called myBank, myBank.moveToSavings() should transfer my original $150 from my spending account into my savings account and my spending account should be 0. Hint: Make sure both setter methods you write are void methods Hint: When transferring money from spending to savings, make sure you set spending back to 0.
Bank Class (settter methods) You have a class called Bank that keeps track of how much money you have in your "Bank account". You are provided with the constructor and the accessors, but you need to write the setter methods for this class. Write a method called addMoney to add money to the "spending account" (this is your spendings variable), and another method that transfers" all of your money from your spending account into your savings account (this is your savings variable). E.g. 1: If I had a Bank object called myBank, myBank. addMoney (150.0) should add $150 to my spending account E.g. 2: If I had a Bank object called myBank myBank. moveTo Savings() should transfer my original $150 from my spending account into my savings account and my spending account should be 0. Hint: Make sure both setter methods you write are void methods Hint: When transferring money from spending to savings, make sure you set spending back to 0. 1 public class Bank { 2 private double spending: 3 private double savings; 6 7 public Bank () { this. spending = 0.0: this. savings = 0.0: } 8 9 10 11 12 13 14 15 public double getSpending 0 { return this. spending: } public double getSavings() { return this. savings: } 16 17 18 19 20 21 //Write a method called addMoney to add money to the spending account //TODO: add the addMoney method here public double getSpending o { return this. spending: } public double getSavings() { return this. savings; } //Write a method called addMoney to add money to the spending account //TODO: add the addMoney method here //Write a method called moveTo Savings that transfers all the money in spending to savings //TODO: add the moveToSavings method here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
