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
Discuss the use of distributed (federated) authentication systems in use at your institution. If no such system is in use, then
aleksklad [387]

Answer:

Check the explanation

Explanation:

Distributed (federated) authentication system:

  1. • Federal identity in a information technology is a process of linking a person's identity and the attributes in multiple distinct identity management system.
  2. • It uses a single sign-on authentication; it means that one authentication credential is used to access multiple applications or the accounts.

Use of distributed (federated) authentication systems in institutions

In the institution the educational resources and other splices are offered via online, the faculty, students, alumni or other users using are accessing the resources from the various locations.

Different devices like mobile, tablet, laptop, desktop are used to access those resources.

The distributed or federated authentication identity management permits the institution to provide the access in a trustworthy, protected manner without n explosion a credentials.

• She distributed or federated authentication identity management permits the institution or individual faculty to control the access of research or other data easily and enables new level of academic collaboration

• It support the institutional policies to emend the access of valuable resources to a specific groups a use, and the incorporation of identity management across the academic government and commercial add and it make wider the possibility for interdisciplinary, inter-institutional scholarship.

BENEFITS

Students

• Make them to remember to single user id and password.

• Makes to access the educational resources across the institution and world.

• Personal information's are securely protected.

Teachers and Researchers

• flaps to create learning and research tools.

• It makes the control to access the restricted crown .

• It follows the Federal regulations and streamlines the access to the federal grant system

IT

• It eliminate the data and system redundancy

• Provides a strong and secure identity and access management.

4 0
4 years ago
Diane changes the size of an image with the format picture pane and keeps the original ratio of height to width of the object. W
bixtya [17]

Answer:

it's d.  

Explanation: post protected

7 0
3 years ago
What is the processing speed for the second generation of computers​
natima [27]

Answer:

10mbps

Explanation:

that's what the internet says

5 0
3 years ago
Ive tried everything how can i get my images back ?
anzhelika [568]
What do you mean did you refresh the page
3 0
3 years ago
Read 2 more answers
How does an author develop a character in a story
gavmur [86]
An author first comes up with a basic idea, like male or female for example. Then personality traits take place. Character design can be decided before personality traits too, sometimes it helps authors come up with different ideas. Next personal relationships can be included.
4 0
3 years ago
Read 2 more answers
Other questions:
  • 1. Why was the Internet created?
    8·1 answer
  • Where is the BIOS stored?<br><br> CPU<br> CMOS<br> RAM<br> Northbridge
    13·2 answers
  • To cope with the uncertainty about how their pages will be viewed, many web page designers opt to use _________ units, which are
    13·1 answer
  • Consider a file/directory with the following info:
    14·1 answer
  • Refer to the exhibit. What kind of NAT is configured on the ASA device?
    10·1 answer
  • What type of platform is SAP?
    9·1 answer
  • Identify the programmer’s responsibility in maximizing the programs reliability by having awareness of the beneficial and harmfu
    8·1 answer
  • What is the difference between an html opening tag and a closing tag?.
    7·1 answer
  • How does the dns help the world wide web scale so that billions of users can access billions of web pages?.
    6·1 answer
  • Evaluating sorts given the following array: 41, 32, 5, 8, 7, 50, 11 show what the array looks like after the first swap of a bub
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!