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
Jim has just purchased two new SCSI hard disk drives and a controller card for them. He properly installs the hardware in his ma
yawa3891 [41]

Answer:

  • Create partitions on each hard disk drives.
  • Mount the partition created on each hard drive so they are accessible by the the operating system.
  • Format the partitions created with a filesystem recognized by Linux.

Explanation:

Having purchased the two new SCSI hard disk drives with the controller cards for each and installed them properly, before using them for data storage and retrieval he must first use the fdisk command to create one or more partitions on each of the hard disk drives then mount any partitions created on the two hard drives so that they are accessible by the operating system before then proceeding to format any partitions created with a valid filesystem recognized by Linux.

4 0
3 years ago
Is It Safe to Use LinkedIn Automation?
Stolb23 [73]

Answer:

A lot of people have claimed that they lost their full-established accounts after using LinkedIn automation tools. LinkedIn detected the activity and blocked their accounts.  

But it’s not the tool that causes spam, it’s the approach you adopt while using these tools.  

Many people think that LinkedIn automation tools(LinkedCamp) can generate leads magically over the night. They send thousands of connection requests and messages using automation and as a result, LinkedIn detects their activity.  This is not how it works. You need a proper strategy to leverage the potential of these tools. Even the best LinkedIn automation tools cannot guarantee success if you try to overdo the activities.

6 0
3 years ago
Read 2 more answers
Discuss one simple example of hybrid computer.​
andrezito [222]

Answer:

thermometer , petrol pump

5 0
2 years ago
How you will install an operating system on your computer
defon
Someone can install an operating system by disk or removable storage media.

Disk being floppy, tape or commonly a DVD.

Removable storage being a USBdrive.
5 0
3 years ago
A computer never gets tired or bored while working for a long time .. ​
Angelina_Jolie [31]

Answer :Computers never get tired or bored because of doing the same task continuously. They work in the same manner all the time. A computer can store large amount of information in its memory.

Explanation: it is quality which makes the user to be dependent on computer. As we all know, computer systems do repetitive tasks without any boredom, tiredness, or fatigue.

5 0
2 years ago
Other questions:
  • Write a function removeEvens to remove all the even numbers from input row array inRowArray which contains integer numbers. The
    15·1 answer
  • Keion works as a freelancer creating websites and designing logos for clients. He recently had a hard drive failure and lost wor
    7·1 answer
  • The approved systems design document is used by programmers, the personnel department, and information systems personnel.
    8·1 answer
  • Why is exception handling an issue for testers in object-oriented developments?
    15·1 answer
  • Mia is attending a team meeting to discuss how to prevent accidents. One of her teammates suggests pushing all the desks against
    15·2 answers
  • The function below takes a string argument sentence. Complete the function to return the second word of the sentence. You can as
    5·1 answer
  • Which of the following is a default letter assigned for the primary hard drive
    6·2 answers
  • In a registration database, Ross has tables for student, professor, classroom, class, class-hour. Since his campus has about 12,
    9·1 answer
  • . How is using 0 / 1 or true / false in specifying digital an abstraction?
    11·1 answer
  • 9.19 LAB: Words in a range (lists) Write a program that first reads in the name of an input file, followed by two strings repres
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!