Answer: Provided in the explanation section
Explanation:
#include<iostream>
using namespace std;
class Money{
private:
int all_cents;
public:
Money();
double get_value() const;
Money(int,int);
void printamount();
friend Money operator+(const Money&, const Money&);
friend ostream& operator<<(ostream&, const Money&);
friend istream& operator>>(istream&, Money&);
};
Money::Money(){all_cents=0;}
double Money::get_value() const{return all_cents/100.0;}
Money::Money(int dollar ,int cents){
all_cents = dollar*100+cents;
}
void Money::printamount(){
cout<<"$"<<get_value()<<endl;
}
Money operator+(const Money& m1, const Money& m2){
int total_cents = m1.all_cents + m2.all_cents;
int dollars = total_cents/100;
total_cents %=100;
return Money(dollars,total_cents);
}
ostream& operator<<(ostream& out, const Money& m1){
out<<"$"<<m1.get_value()<<endl;
return out;
}
istream& operator>>(istream& input, Money& m1){
input>>m1.all_cents;
return input;
}
int main(){
Money m1;
cout<<"Enter total cents: ";
cin>>m1;
cout<<"Total Amount: "<<m1;
Money m2 = Money(5,60);
Money m3 = Money(4,60);
cout<<"m2 = ";m2.printamount();
cout<<"m3 = ";m3.printamount();
Money sum = m2+m3;
cout<<"sum = "<<sum;
}
cheers i hope this helped !!