#include <iostream>
#include "Invoice.h"
using namespace std;
int main() {
string description;
double price;
int quantity;
cout << "Enter the description: ";
getline(cin, description);
cout << "Enter the unit price: ";
cin >> price;
cout << "Enter the quantity: ";
cin >> quantity;
cout << endl;//a new line
//create an invoice using default constructor
Invoice hammers;
hammers.setDescription(description);
hammers.setPrice(price);
hammers.setQuantity(quantity);
//now print the invoice
hammers.print();
cout << endl;
//create an invoice using constructor with parameters
Invoice ductTape("Duct Tape",2.99,10);
cout << "[Invoice for object created using constructor]" <<endl;
ductTape.print();
cin.ignore(255,'\n');//ignore any leftover new lines
cin.get();//pause the output...
return 0;
}
***********************
^^^end of code for .cpp file.. here is the code for my Invoice.h file..
***********************
#include <iostream>
#include <string>
using namespace std;
class Invoice
{
public:
void hammers(string bagofhammers);
{
setDescription = bag of hammers;
}
void hammers(int);
{
setQuantity = 1;
}
void hammers (int);
{
setPrice = 12.99;
}
void ductTape (string, int);
{
void setDescription ( string description);
setDescription = Duct Tape;
void setPrice
setPrice = 2.99;
setQuantity = 10;
}
string getDescription()
{
return description;
}
string getQuantity()
{
return quantity;
}
string getPrice()
{
return price;
}
void print()
{
cout <<"Invoiced item is: " << getDescription << endl;
cout <<"Quantity ordered: "<< getQuantity << endl;
cout <<"Each unit's price is: "<< getPrice << endl;
cout <<"Total Amount: "<< (setPrice*setQuantity) << endl;
};
}
**************
i feel like im way off on making it work, but its probably simple to fix.... heres the directions to this problem, below.
thanks so much if you help me with this.
Write a C++ class definition that will model an Invoice for some purchase. An invoice contains the item description,
the unit price (in dollars), the quantity purchased, and the total amount (price * quantity).
Your class definition needs to support setting all of the data members (except total amount), getting all of the data
members, a default constructor, and a constructor that takes in all of the necessary data for an invoice. In addition,
provide a print method that will print a copy of the Invoice object in an easy to read format.
I need my code once run to look like this:
Enter the description: bag of hammers
Enter the unit price: 12.99
Enter the quantity: 1
********
Invoice
********
Item:.........................bag of hammers
Unit Price:...................$12.99
Quantity:.....................1
Total Amount:.................$12.99
[Invoice for object created using constructor]
********
Invoice
********
Item:.........................Duct Tape
Unit Price:...................$2.99
Quantity:.....................10
Total Amount:.................$29.90