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
In risk management what does risk evaluation involved
VLD [36.1K]

Answer:

Explanation:Risk management is the decision-making process involving considerations of political, social, economic and engineering factors with relevant risk assessments relating to a potential hazard so as to develop, analyze and compare regulatory options and to select the optimal regulatory response for safety from that hazard.

5 0
3 years ago
What is the future of web development
Anna35 [415]

Answer:

Creating websites that can execute automated tasks and new programing languages revolving around web development.

Explanation:

7 0
2 years ago
rapid prototyping could be an advantageous methodology for developing innovative computer-based instruction. Software engineers
frosja888 [35]

The option that is true for the Student Version above is option d:  This is not plagiarism.

<h3>What is plagiarism?</h3>

This is known to be the act of copying other people's work and then taking it as your own.

When you look at the student work, you will see some measures od differences. Hence, The option that is true for the Student Version above is option d:  This is not plagiarism.

Learn more about prototyping  from

brainly.com/question/14743515
#SPJ1

See  full question below

Original Source Material

There is a design methodology called rapid prototyping, which has been used successfully in software engineering. Given similarities between software design and instructional design, we argue that rapid prototyping is a viable method for instructional design, especially for computer-based instruction.

Student Version

Rapid prototyping could be an advantageous methodology for developing innovative computer-based instruction. Software engineers have been successful in designing applications by using rapid prototyping. So it also could be an efficient way to do instructional design.

Which of the following is true for the Student Version above?

a. Word-for-Word plagiarism

b. Paraphrasing plagiarism

c. This is not plagiarism

8 0
2 years ago
What is the main task of the project manager
WINSTONCH [101]

Answer:

to handle day to day operations of a project A P E X

Explanation:

hope that helped

6 0
3 years ago
Read 2 more answers
What did early computers use to store each bit?
Damm [24]

Answer:

A vacuum tube

4 0
3 years ago
Read 2 more answers
Other questions:
  • Which Of the following components leads to slow computer performance when it becomes outdated
    12·2 answers
  • Preesure is drived quantity? why​
    15·2 answers
  • When dealing with a person who is behaving violently you should argue with them. A. False B. True
    5·1 answer
  • The reason the Code uses the term ____ instead of motor is that, in many instances, the motor is inside an enclosure and is out
    12·2 answers
  • Consider three different processors P1, P2, and P3 executing the same instruction set. P1 has a 3 GHz clock rate and a CPI of 1.
    8·1 answer
  • Why is printer an output device​
    14·2 answers
  • Can someone help me i need to write something for cyber bullying
    11·2 answers
  • How to automatically forward text messages to another phone iphone.
    10·1 answer
  • Anyone knows the answer for 6.1.4 Happy Birthday! codehs
    13·1 answer
  • Consider the following variable declarations and initializations.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!