The Money Class

Purpose:

Instance variables:

   private int dollars;  //  number of dollars

   private int cents;  //  number of cents

Usage: (public methods)

Constructors:

   Money  m1 = new Money();           //  Default constructor -- initial value is 0 dollars and 0 cents
   Money  m2 = new Money(int d, int c); //  Initialize constructor: dollars = d and cents = c
   Money  m3 = new Money(Money m); //  Copy constructor

Accessors:

·         Access the number of dollars
·         Access the number of cents

Modifiers:

·         Set the number of dollars
·         Set the number of cents
·         A private method normalize method that converts an improper cents amount to dollars (for example, if dollars is 4 and cents is 112, normalize will correct these to 5 dollars and cents 12)

Other Methods:

·         Display the money amount in proper format ($12.34)    // a toString method
·         Add two money amounts together and return the result
·         Subtract one money amount from another and return the result
·         Multiply an integer times a Money object and return the result (this would allow for calculations such as purchasing multiple items of the same price).
·         Divide a Money amount by an integer and return the result (this would allow for calculations such as splitting a cost evenly among several people).