(Solved) : 2 Modify Money Class Provided Note Class Similar One Tutorial 3 Completed Tutorial 3 Feel Q34608875 . . .


Ineed help please2) Modify the Money class that is provided. Note that this class is very similar to the one from Tutorial 3. If you have completed Tutorial 3, feel free to copy code from there to here to help with this problem. Look at the provided Money class here to see what is different from the previous tutorial. The Money class is a simple class that stores money as dollars and cents. For example, $12.73 vwill be stored as 12 dollars and 73 cents. The cents value stored should never be greater than 99, so 3 dollars and 164 cents should actually be stored as 4 dollars and 64 cents. The class has only one method, toString0, which returns a String representation of the money object. Here we have overridden the toString0 method inherited from Object. Your first task is to create four constructors for the class as follows: public Money (String name.. // create an object with zero dollars and cents. // sets the name of the object public Money (String name, int c)…) // create an object with c cents // (adjusting dollars and cents so that os-cents<-99) // sets the name of the object public Money (String name, int d, int c)t…) // create an object with d dollars and c cents // (adjusting dollars and cents so that 0s-centsc-99) // sets the name of the object pubic Money (String name, int[1 coins)…) pubic Money (String name, int[l coins)(…) // input array has 6 elements and corresponds to // {tooní es, #loonies, #quarters, #dines, #nickels , #pennies) / 182, $1, $0.25, $0.10, $0.05, $0.01) // create an object with total money passed in array // (adjusting internal dollars and cents so that 0< cents<-99) // sets the name of the object In all the constructors, be sure thiat the internal state (dollars and cents) represents the total money and that cents is not greater than 99. The Money class overrides the toString0 from the Object class.You can use it to help test/debug your code. It returns a String representation of the money Use the testing program TestMoney java to help test your constructors. Next, add the following instance methods to your Money class: public void add (int c)i…) // adds c cents to the current value // Again, be sure the internal states // does not have cents greater than 99 public void add (int d, int c)..) // adds d dollars and c cents to the current value // Again, be sure the internal states // does not have cents greater than 99 public int remove (int c)f… // removes c cents from the current amount of money, // if there is enough money to remove c cents Next, add the following instance methods to your Money class: public void add (int c) (…) // adds c cents to the current value // Again, be sure the internal states /I does not have cents greater than 99 public void add (int d, int c).. // adds d dollars and c cents to the current value // Again, be sure the internal states /I does not have cents greater than 99 public int remove(int c) // removes c cents from the current amount of money, // if there is enough money to remove c cents. // Otherwise, removes as much as it can. // Returns the actual amount removed. // Note: the input will satisfy >-0 (and it may be > 100). Be sure to test your methods. Pay special attention to the remove method. As with the constructors, the intention is 99 at all times. Adjust your that your internal representation of the money will satisfy the condition 0 ss cents dollars and cents so that this is always maintained. In the TestMoney class, add three new tests ( one for addint), one for addlint, int) and one for removeüint) More Reading Show transcribed image text
Expert Answer
Answer to 2 Modify Money Class Provided Note Class Similar One Tutorial 3 Completed Tutorial 3 Feel Q34608875 . . .
OR