
Define a class named Money whose objects represent amounts of U.S. money. The class will have two instance variables of type int for the dollars and cents in the amount of money. Include a constructor with two parameters of type int for the dollars and cents, one with one parameter of type int for an amount of dollars with zero cents, and a no-argument constructor. Include the methods add for addition and minus for subtraction of amounts of money.
These methods should be a static methods and should each have two parameters of type Money and returns a value of type Money. Include a reasonable set of accessors (getter) and mutator (setter) methods as well as the methods equals and toString. Add a second version of the methods for addition and subtraction. These methods should have the same names as the static version but use a calling object and a single argument. For example, this version of add method (for addition) has calling object and one argument.
So m1.add(m2) returns the result of adding the Money objects m1 and m2. Note that your class should have all these methods; for example, there should be two methods named add.
Write a test program for your class.
Notes: You will need to implement the following methods:
â?? int getCents() â?? int getDollars() â?? void setDollars(int dollars) â?? void setCents(int cents) â?? boolean equals(Money amount) â?? static Money add(Money amount1, Money amount2) â?? static Money minus(Money amount1, Money amount2) â?? Money add(Money m) â?? Money minus(Money m) â?? String toString()