Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- struct product {
- long int barcode;
- string name;
- float weight;
- float price;
- int quantity;
- };
- int n;
- product prod[50];
- product* q;
- q = prod;
- float total=0;
- cout << "Enter a number of products: "<<endl;
- cin >> n;
- cout << "Product info: " << endl;
- for (int i = 0; i < n; i++) { //loop for inputting product info
- cout << "Product number "<<i+1<<": "<<endl;
- cout << "Enter barcode: "<<endl;
- cin >> q->barcode;
- cout << "Enter name: " << endl;
- cin >> q->name;
- cout << "Enter weight: " << endl;
- cin >> q->weight;
- cout << "Enter price: " << endl;
- cin >> q->price;
- cout << "Enter quantity: " << endl;
- cin >> q->quantity;
- total = total+ (q->price*q->quantity);
- q++;
- }
- cout << "The "<<n<<" types of products cost a total of "<<total;
- }
Advertisement
Add Comment
Please, Sign In to add comment