Geek-aka HW2

profilela_bluu

Create a class called Invoice that a hardware store may use to represent an invoice for an item sold at the store.  The class should have four (4) instance variables: 

  • part number : string
  • part description : string (what is the item)
  • quantity being purchased : int
  • price per item : double

Create a constructor that initializes the four data members.  Also use default parameters with your constructor.  Create an accessor and mutator for each data member as well.  

Create a member function named getInvoiceAmount that calculates the invoice amount. If the quantity is less than 0, it should be set to 0. If the price per item is also negative, that should be set to 0 as well.

You may create a function that dsplays the receipt.

For extra credit, write a method to overload the ostream and istream operators so any object of the class can be displayed in a cout statement and the object values can be inputted using cin.  E.g.

Invoice i;
cin >> i;
cout << i;

    • 12 years ago
    • 20
    Answer(2)

    Purchase the answer to view it

    blurred-text
    • attachment
      programupdated.cpp

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      invoice_answer.docx
    Bids(0)