HELP ME FIX THIS CODE

I need help with # 4

We need a point of sale system for the new grocery store I am planning to open. Here are the main features of this program:

1) Enter a Product
This feature allows user to enter a new product into the system. Program asks store owner to enter a product name (ex. Snicker, SpringWater etc), quantity (how many of this product in inventory), and sale price. Assume that product name does not have any space in it. If the product already exist, tell store owner that the product is already in inventory.

2) Change Inventory
This feature allows store owner to change the quantity of a product in the inventory. Program asks user for the name of the product and new quantity. It will search the products in the system, find the product user specified and change its quantity to the new number specified by store owner.

3) Make Sale
This feature allows store owner to record the sale of a product. Program asks user for the name of the product and how many of this product is sold. It will search the products in the system, find the product user specified and deducts the specified quantity from the inventory.

4) Inventory Report
This feature allows store owner to display inventory report. The report should display each product on a separate line. For each product, display the name, sale price and quantity. At the end of the report also display the worth of the whole inventory. worth of each product is quantity of that product times the sale price. the worth of the whole inventory is the sum of the worth of all products.


5) Exit
Exits the program.

Each feature should be in its own function. Make sure to create a class for product. Product class will have product name, quantity and sale price as fields. You need an array of Product class to hold on to different products in the system.

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <string>

using namespace std;

class GroceryRecord
{
public:
    string Name;
    int Quantity;
};


void EnterProduct(GroceryRecord Grocerystuff[], int GroceryCount)
{
    GroceryRecord gr;

    cout << "Enter name of product: ";
    cin >> gr.Name;
    cout << "Enter the Quantity of product: ";
    cin >> gr.Quantity;

    cout << endl;
    cout << "You Entered" << endl;
    cout << "Name: " << gr.Name << endl;
    cout << "Quantity: " << gr.Quantity << endl << endl << endl;

    Grocerystuff[GroceryCount]  = gr;
}

int main()
{
    GroceryRecord Grocerystuff[100];
    int GroceryCount = 0;

    while(true)
    {
        cout << "1- Enter a Product" << endl;
        cout << "2- change Inventory" << endl;
        cout << "3- Make Sale" << endl;
        cout << "4- Inventory Report" << endl;
        cout << "5- Exit" << endl;
        cout << "What is your choice? ";

        int choice;
        cin >> choice;

        if(choice == 5) 
            break;

        if (choice == 1)
        {
            EnterProduct(Grocerystuff, GroceryCount);
            GroceryCount++;
        }
else if(choice == 2)


		}
        else if(choice == 3)
		
        else if(choice == 4)

		}
	}




    system("PAUSE");
    return 0;
}
Last edited on
Read your code. You do deduct something from somewhere with the -= operator. What are the sides of that statement?

What if the customer buys more than one? What if tbe customer wants more than the inventory has?
can you please be clearer. i thought i a deducting the quantity. how can i fix my problem. what do i need to do?
You don't even ask the user for amount. You decrease some temporary variable by the amount there is product in stock.
thanks for the hint. now i need help with #4
how do i get the sum of all products?
See std::accumulate
Topic archived. No new replies allowed.