1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vesna [10]
3 years ago
13

Consider the class Money declared below. Write the member functions declared below and the definition of the overloaded +. Modif

y the class declaration and write the definitions that overload the stream extraction and stream insertion operators >> and << to handle Money objects like $250.99
Write a short driver main() program to test the overloaded operators +, << and >> class Money { public: friend Money operator +(const Money& amountl, const Money& amount2) Money(); // constructors Money( int dollars, int cents); // set dollars, cents double get_value() const; void printamount();// print dollars and cents like $12.25 private: int all_cents; // all amount in cents };

Computers and Technology
1 answer:
disa [49]3 years ago
5 0

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 !!

You might be interested in
Select the correct answer.
tia_tia [17]

Answer:

A

Explanation:

HTML is a coding language.

8 0
3 years ago
Type the correct answer in the box. Spell the word correctly.
aev [14]

Answer:if you are looking for video and audio data its mp4

Explanation:

there is no explaination

8 0
3 years ago
Read 2 more answers
Source code is one particular representation of a software system. It highlights some details and hides others. This is a good e
grigory [225]

Answer:

Abstraction

Explanation:

Under fundamental principles of software engineering, the term "abstraction" is simply defined as the act of highlighting some details and hiding other ones.

Thus, the correct answer among the options is Abstraction.

8 0
2 years ago
Suppose you draw two cards from a standard deck of 52 playing cards. What is the probability that they are both sixes? Keep at l
GaryK [48]

Answer:

0.00452

Explanation:

There are 4 sixes in a deck. So the chance that the first card you draw is a six, is 4/52. Then there are only 3 sixes left and 51 cards. So the chance that the second one is also a six is 3/51.

The combined chance is the multiplication, i.e., 4/52 * 3/51 = 0.00452

7 0
3 years ago
Int someFct (int N)[
Allisa [31]

Answer:

solution attached.

Explanation:

Also, the tetha time complexity of T_upper would be 2^{\frac{n}{3} }

3 0
2 years ago
Other questions:
  • What is the final step used when designing an algorithm?
    14·1 answer
  • Use the variables k and total to write a while loop that computes the sum of the squares of the first 50 counting numbers, and a
    10·1 answer
  • Playstation 4 how to change mtu settings
    12·1 answer
  • We have three containers whose sizes are 10 pints, 7 pints, and 4 pints, respectively. The 7-pint and 4-pint containers start ou
    14·2 answers
  • When you are saving a file, what does word suggest by default as the name of the document?
    8·2 answers
  • What is the value of numX when this program is executed? if 3 &lt; 5 and 8 != 3: numX = 3 else: numX = 7
    13·2 answers
  • ____allow(s) visually impaired users to access magnified content on the screen in relation to other parts of the screen.
    5·1 answer
  • True or False: At the Company level, users will only have access to view projects to which they have been specifically granted a
    5·2 answers
  • It's generally best to use what types of sites for factual internet research? Select all that apply from the choices below.
    5·2 answers
  • ______________ are used to store information that will be referenced and manipulated in a computer program. They label data with
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!