Question: Define a class named Cash to store an amount. Here is the functionality that your class should provide. Code in c++ Your class should create

Define a class named Cash to store an amount. Here is the functionality that your class should provide. Code in c++

Your class should

create an object from two integers, the dollars portion and the cents portion

create an object from a single integer: this integer corresponds to just the dollars

create an object with a no-arg, default constructor that sets the Cash amount to $0.00

get the dollars (the value returned should be an int): this is an accessor function

get the cents (the value returned should be an int): this is an accessor function

get the Cash amount as a double: this is an accessor function

set the dollars and cents with two integers in a single function: this is a mutator function

set the dollars and cents with an amount of type double: this is a mutator function

overload the operator << to output in the format $ddd.cc where $ is the dollar sign d is one more digits corresponding to the dollars digits ddd could correspond to 0) a fixed decimal point 2 digits for the cents (possibly 00): the 2 is called Cash::DIGITS_OF_CENTS in Cash.h There could be a negative sign before the dollar sign as in -$7.31

overload the operator >> for input the first integer read is the dollars, the second integer is the cents. Do not do any output in the input function operator >>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!