Linked List

well this is the receiving part of the program that i have wrote so far , still have to add the choice at the start .it could be like (for selling press S ,for receiving press R and P) help please......

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>
#include<stack>
using namespace std;

struct widgetRecord {
    int quantity;
    double price;
    widgetRecord(int q, double p): quantity(q), price(p) { }
};

int main() {
    stack<widgetRecord> widgets;
    int q;
    double p;
    int N;
    cout << "Enter how many types of widgets recieved: " << endl;
    cin >> N;
    cout << endl << "Enter the quantity and prices of recieved widgets: " << endl;

    for (int i = 0; i < N; i++) {
        cout << endl << "Enter the quantity of item # " << (i + 1) << ": ";
        cin >> q;
        cout << "Enter the price for each item: ";
        cin >> p;
        widgets.push(widgetRecord(q,p));
        cout << endl;
    }

    cout << endl << "Quantity : Prices" << endl;

    for (int i = 0; i < N; i++) {
        widgetRecord widget = widgets.top();
        cout << endl << widget.quantity << " : " << widget.price << endl;
        widgets.pop();
    }

    system("pause");
}
From what you have written so far you should be able to make a starting menu pretty easily.

What specifically are you having trouble with?

I would recommend not using system("pause"); it is slow and OS dependent, just use cin.get(); to pause your program at the end instead.
Last edited on
Topic archived. No new replies allowed.