Question: Java Programming Just write the toString method. NOTE: Do not use/write a main method. The toString method-->Provides a string representation of the current Money object,
Java Programming
Just write the toString method.
NOTE: Do not use/write a main method.
The toString method-->Provides a string representation of the current Money object, in the form $mm.mm. Negative values have a minus sign before the dollar sign. Zero dollar amounts are represented with one zero between the dollar sign and the decimal point. Cents that are multiples of 10 still show two decimal places. (Examples: $12.34, -$6.50, $0.99, -$0.99, $0.00) @return the string representation
Rules
A negative value is represented with both dollars and cents. Example --> If a new money object is created with 7 dollars and -25 cents, it should be converted to 6 dollar and 75 cents. Adding and subtracting should never alter either the implied or actual parameter and should result in a new money object. Example --> Adding $1.99 and $0.05 should result in a Money object of 2 dollars and 4 cents. The toString method should result in the following style: --> $18.74 --> -$2.73 --> $9.99 --> -$9.99 --> $0.00

Money fleaf -dollars: long -cents: byte +Money) +Money(dollars:long, cents: byte) +getDollars(0: long +getCents(): byte +add(other: Money): Money +subtract(other: Money): Money +toString): String
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
