0% found this document useful (0 votes)
8 views3 pages

Knowledge

The document defines an Invoice class with private member variables for part number, description, quantity, and price. It includes public setter and getter methods for each member variable as well as a method to calculate the invoice amount by multiplying quantity and price. The main function creates an Invoice object and outputs its details to the console.

Uploaded by

pilixo7957
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Knowledge

The document defines an Invoice class with private member variables for part number, description, quantity, and price. It includes public setter and getter methods for each member variable as well as a method to calculate the invoice amount by multiplying quantity and price. The main function creates an Invoice object and outputs its details to the console.

Uploaded by

pilixo7957
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Task no 1 :

#include <iostream>
#include <string>
using namespace std;
class Invoice {
private:
string partNumber;
string partDescription;
int quantity;
int pricePerItem;
public:
Invoice(string pn, string pd, int q, int p) {
setPartNumber(pn);
setPartDescription(pd);
setQuantity(q);
setPricePerItem(p);
}
void setPartNumber(string pn) {
partNumber = pn;
}
void setPartDescription(string pd) {
partDescription = pd;
}
void setQuantity(int q) {
if (q > 0) {
quantity = q;
} else {
quantity = 0;
}
}
void setPricePerItem(int p) {
if (p > 0) {
pricePerItem = p;
} else {
pricePerItem = 0;
}
}
string getPartNumber() {
return partNumber;
}
std::string getPartDescription() {
return partDescription;
}
int getQuantity() {
return quantity;
}
int getPricePerItem() {
return pricePerItem;
}
int getInvoiceAmount() {
return quantity * pricePerItem;
}
};
int main() {
Invoice invoice("PN123", "Hammer", 2, 19.99);
cout << "Part Number: " << invoice.getPartNumber() <<endl;
cout << "Part Description: " << invoice.getPartDescription()
<<endl;
cout << "Quantity: " << invoice.getQuantity() <<endl;
cout << "Price Per Item: " << invoice.getPricePerItem() <<
endl;
cout << "Invoice Amount: " << invoice.getInvoiceAmount() <<
endl;
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy