Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need parts a through d please Problem 4 (2 points). Design and implement a Money class for calculations involving dollars and cents where arithmetic has
need parts a through d please
Problem 4 (2 points). Design and implement a Money class for calculations involving dollars and cents where arithmetic has to be accurate to the last cent using the 4/5 rounding rule (.5 of a cent rounds up; anything less than .5 rounds down): (a) Represent a monetary amount as a number of cents in a long, but input and output as dollars and cents, e.g., $123.45. Do not worry about amounts that don't fit into a long. (b) Provide addition (Money + Money), subtraction (Money - Money), multiplication (Money * int or Money * double), and division (Money / int or Money / double) operators. (c) Define corresponding input (>> and output (>) that reads monetary amounts with currency denominations, such as USD 1.23 and EUR 5.00, into a Money variable. Also define a corresponding output operator (Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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