Question
Java Define a class named Money whose objects represent amounts of U.S. money. The class should have two instance variables of type int for the
Java
Define a class named Money whose objects represent amounts of U.S. money. The class should 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 constructor of type int for an amount of dollars with zero cents and a no-argument constructor. Include the methods add and minus for addition and subtraction of amounts of money. These methods should be static methods, should each have two parameters of type Money, and return a value of type Money. Include a reasonable set of accessor and mutator methodsas well as the methods equals and toString. Write a test program for your class.
Sample Output
Enter dollar:101
Enter cents:01
$101.01
Enter dollar:99
Enter cents:99
$99.99
$201.00
$1.02
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started