Answer:
#include<iostream>
using namespace std;
class Money{
private:
int dollars;
int cents;
public:
Money(int d=0, int c=0){
setDollar(d);
setCent(c);
}
void setDollar(int d){
dollars = d;
}
void setCent(int c){
cents = c
}
int getDollar() {
return dollars;
}
int getCent() {
return cents;
}
double getMoney(){
return (dollars + (cents/100));
}
};
// testing the program.
int main(){
Money Acc1(3,50);
cout << M.getMoney() << endl;
Money Acc2;
Acc2.setDollars(20);
Acc2.setCents(30);
cout <<"$" << Acc2.getDollars() << "." << Acc2.getCents() << endl;
return 0;
}
Step-by-step explanation:
The C++ source code defines the Money class and its methods, the class is used in the main function as a test to create the instances of the money class Acc1 and Acc2.
The object Acc2 is mutated and displayed with the "setDollar and setCent" and "getDollar and getCent" methods respectively.