#include<iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using namespace std;
class Invoice
{
public:
void setPrice(int price);
int getPrice();
void setQuantity(int quantity);
int getQuantity();
void setPartnumber(string);
string getPartnumber();
void setDescription(string);
string getDescription();
int getInvoiceAmount(int Quantity, int Price);
private:
int Quantity;
int Price;
string Partnumber;
string Description;
};
void Invoice::setPrice( int price )
{
if (price >= 0)
price = Price;
else
Price = 0;
}
int Invoice::getPrice()
{
return Price;
}
void Invoice::setQuantity( int quantity )
{
if (quantity > 0)
quantity = Quantity;
else
Quantity = 0;
}
int Invoice::getQuantity()
{
return Quantity;
}
void Invoice::setPartnumber( string partnumber )
{
partnumber = Partnumber;
}
string Invoice::getPartnumber()
{
return Partnumber;
}
void Invoice::setDescription( string description )
{
description = Description;
}
string Invoice::getDescription()
{
return Description;
}
int getInvoiceAmount(int Quantity, int Price)
{
int total;
total = (Quantity * Price);
return total;
}
int main()
{
int price,quantity;
Invoice description();
Invoice partnumber();
cout << "Please enter the part number: ";
cin >> partnumber;
cout << "\nPlease enter the description: " ;
cin >> description;
cout << "Please enter the price: ";
cin >> price;
cout << "\nPlease enter quantity: " ;
cin >> quantity;
partnumber.setPartnumber(partnumber);
description.setDescription(description);
Invoice::setPrice(price);
Invoice::setQuantity(quantity);
cout << "Your invoice is as follows:" << endl << endl
<< "Part Number: " << Invoice.getPartnumber() <<endl
<< "Description: " << Invoice.getDescription() << endl
<< "Price: " << Invoice.getPrice() << endl
<< "Quantity: " << Invoice.getQuantity() <<endl
<< "Total Cost: " << Invoice.getInvoiceAmount() << endl;
return 0;
}
gmerch80 0 Newbie Poster
Nick Evan 4,005 Industrious Poster Team Colleague Featured Poster
gmerch80 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
gmerch80 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.