Modify the Money class that is provided. This is a simple class that stores money as dollars and cents. For example, $12
Posted: Thu Jul 14, 2022 2:19 pm
Modify the Money class that is provided. This is a simple class that stores money as dollars and cents. For example, $12.73 will 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 be stored as 4 dollars and 64 cents. The class has only one method, toString (), which returns a String representation of the money object. Your first task is to create THREE constructors for the class as follows: public Money() {…} // creates a Money object with zero money public Money (int dollars, int cents) {…} // creates a Money object with total value as specified by // the input values. Input values are assumed to satisfy // dollars >=0 and cents >=0. // will always have 0<= cents <=99) public Money (int cents) {…} // creates a Money object with value as specified by / the input cents. Input value is assumed to satisfy // cents >=0 // will always have 0<= cents <=99) In all the constructors, be sure that the internal state (dollars and cents) represents the total money and that cents is not greater than 99 . The Money class has a toStringl ) method to help test/debug your code. It returns a String representation of the money object.