Need some much needed help with a project..

Hello everyone I have a project due soon and it is a inventory management system. I just learned coding and I'm using c++. This project will store the following of two products.

upc (universal product code
manufacturer
product name
price
quantity

This is the menu!

1.Display Products
2.Edit Product
3.Reset Product to Default
4.Exit

1. Will display both products on the screen and the output should look like this
UPC: 0
Manufacturer: Name of Company
Product Name: Name of Product
Price: $0.00
Quantity: 0
Total Value: $0.00

Product 2:
UPC: 0
Manufacturer: Name of Company
Product Name: Name of Product
Price: $0.00
Quantity: 0
Total Value: $0.00

I have menu down I think but I am having trouble using a string to get the Name of Company and Name of Product. I know its a two string variable but for the life of me i cant figure it out.

2. will ask the user to enter all of the products information that the user wants to update while having printed the current values.

3. Will prompt the user and reset the default values!! I have no clue how to properly do this one.. Will I have set values and use those set values when option 3 is chosen?

4. Will exit the program.

here is my code so far.

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <iostream> //needed
#include <string> // for string
#include <iomanip> // for setw()
using namespace std; 

int main ()

{
	int UPC1, quantity1, choice;
	double price1, tValue1;

	int UPC2, quantity2;
	double price2, tValue2;

        // After some late night grinding I finally got the strings down!!!
        string man1 = "Name of Manufacture";
        int size = man1.length();
        string product1 = "Name of Product";
        string man2 = "Name of Manufacture";
        string product2 = "Name of Product";



	int x = -1; // for loop?	

	const int DISPLAY_CHOICE = 1,
		  EDIT_CHOICE = 2,
	          RESET_CHOICE = 3,
		  EXIT_CHOICE = 4;
		 	
	
	cout << "1. Display Products\n"
	     << "2. Edit Product\n"
	     << "3. Reset Product to Default\n"
	     << "4. Exit\n"
	     << "Enter your choice: ";

	cin >> choice;


	int display;
	cout << setprecision(2) << fixed << showpoint;

	if (choice == 1)
        { // good   
	cout << "Would you like to display product 1 or product 2? Enter 1 or 2. " << endl;
	cin >> display;

    if (display == 1)
        { // good
	cout << " Product 1" << endl;
	cout << setw (0) << " UPC: " << setw(11) << UPC1 << endl;
	cout << setw (0) << " Manufacturer: " << setw(5) << man1 << endl;
	cout << setw (0) << " Product Name: " << setw(5) << product1 << endl;
	cout << setw (0) << " Price:        $" << setw(0) << price1 << endl;
	cout << setw (0) << " Quantity: " << setw(5) << quantity1<< endl;
	cout << setw (0) << " Total Value:  $" << setw(0) << tValue1 << endl;
        } // good      

    else if (display == 2)
        { //good   
        cout << " Product 2" << endl;
        cout << setw (0) << " UPC: " << setw(11) << UPC2 << endl;
        cout << setw (0) << " Manufacturer: " << setw(5) << man2 << endl;
        cout << setw (0) << " Product Name: " << setw(5) << product2 << endl;
        cout << setw (0) << " Price:        $" << setw(0) << price2 << endl;
        cout << setw (0) << " Quantity: " << setw(5) << quantity2 << endl;
        cout << setw (0) << " Total Value:  $" << setw(0) << tValue2 << endl;
        } // good
        } // good
    

	if (choice == 2)
        { //good

	cout << "Would you like to edit product 1 or product 2? Enter 1 or 2. " << endl;
	cin >> display;

    if (display == 1)
        { // good	
	cout << "Please enter the Universal Product Code1 or the UPC1." << endl;
        cin >> UPC1;

        cout << "Please enter manufacturer1." << endl;
        cin >> man1;

        cout << "Please enter the product1's name." << endl;
        cin >> product1;

        cout << "Please eneter price1." << endl;
        cin >> price1;

        cout << "Please enter quantity1." << endl;
        cin >> quantity1;
        } // good

    else if (display == 2)
        { // good
 	cout << "Please enter the Universal Product Code2 or the UPC2." << endl;
        cin >> UPC2;

        cout << "Please enter manufacturer2." << endl;
        cin >> man2;

        cout << "Please enter the product2's name." << endl;
        cin >> product2;

        cout << "Please eneter price2." << endl;
        cin >> price2;

        cout << "Please enter quantity2." << endl;
        cin >> quantity2;
	} //good
	} // good



	if (choice == 3)
	{ // good
        cout << "Which product would you like to set to default values?" << endl;
        cout << "Input 1 for product1 or 2 for product2." << endl;
        cin >> display;

	
        if (display == 1)
	{ // good
        cout << "display1" << endl;
	
	} // good




        else if (display == 2)
	{ // good
        cout << "display2 " << endl;
	
	} // good



	} // good ends choice 3








} // good (end)



I have been stuck for days... I'm not asking anyone to do this for me but I'm asking to be pointed in the right direction. I think I have most of the puzzle pieces but I need help bringing it all together. I'll restate what I need help with as little cliff notes:

-on menu option 1 (display products) how I can write the string so that "Name of Manufacture" and "Name of Product" will be printed. (solved)!!!

-on option 2 of the menu how to print the current value.

-on menu option 3 how to reset the values to defaults

-on menu option 4 how to use a infinite loop to continue the program until the user inputs they are done using the program. I will be using the "cancel" as int -1 for as a infinite loop will never reach -1.

Thank you so much and fast replies are always welcomed.
Last edited on
Can you describe in greater detail what you're trying to do? I got a bit lost among your text.
#include <iostream> //needed
#include <string> // for string
#include <iomanip> // for setw()
#include<conio.h>
using namespace std;
int display;
int UPC1=0; int quantity1 =0;
string man1, product1;
double price1=0;int tValue1=0;

int UPC2=0 ;int quantity2=0;
string man2, product2;
double price2=0 ;int tValue2=0;
int menue();
int menue4()
{
cout << "Which product would you like to set to default values?" << endl;
cout << "Input 1 for product1 or 2 for product2." << endl;
cin >> display;
return display;
}
void menue3(int y)
{
if (y==1)

{ // good
cout << "Please enter the Universal Product Code1 or the UPC1." << endl;
cin >> UPC1;

cout << "Please enter manufacturer1." << endl;
cin >> man1;

cout << "Please enter the product1's name." << endl;
cin >> product1;

cout << "Please eneter price1." << endl;
cin >> price1;

cout << "Please enter quantity1." << endl;
cin >> quantity1;
} // good
// good
else if(y==2)
{
cout << "Please enter the Universal Product Code1 or the UPC2." << endl;
cin >> UPC2;

cout << "Please enter manufacturer1." << endl;
cin >> man2;

cout << "Please enter the product1's name." << endl;
cin >> product2;

cout << "Please eneter price1." << endl;
cin >> price2;

cout << "Please enter quantity1." << endl;
cin >> quantity2;
}
menue();
}
void menue2(int x)
{
int number=0;
if(x==1)
{ number=1;

// good
cout << " Product "<<number<< endl;
cout << setw (0) << " UPC: " << setw(11) << UPC1 << endl;
cout << setw (0) << " Manufacturer: " << setw(5) << man1 << endl;
cout << setw (0) << " Product Name: " << setw(5) << product1 << endl;
cout << setw (0) << " Price: $" << setw(0) << price1 << endl;
cout << setw (0) << " Quantity: " << setw(5) << quantity1<< endl;
cout << setw (0) << " Total Value: $" << setw(0) << tValue1 << endl;
menue();}
else
{ number=2;

// good
cout << " Product "<<number<< endl;
cout << setw (0) << " UPC: " << setw(11) << UPC2 << endl;
cout << setw (0) << " Manufacturer: " << setw(5) << man2 << endl;
cout << setw (0) << " Product Name: " << setw(5) << product2 << endl;
cout << setw (0) << " Price: $" << setw(0) << price2 << endl;
cout << setw (0) << " Quantity: " << setw(5) << quantity2<< endl;
cout << setw (0) << " Total Value: $" << setw(0) << tValue2 << endl;
menue();}
// good

}
int menue()
{
int selection;
cout << "1. Display Products\n"
<< "2. Edit Product\n"
<< "3. Reset Product to Default\n"
<< "4. Exit\n"
<< "Enter your choice: ";

cin >> selection;
return selection;
}
int main ()

{
while(1)
{
int call1=menue();
if (call1==1)
{
int call2=menue4();
if(call2==1)
{
menue2(call2);

}
else if(call2==2)
{
menue2(call2);
}
}
if (call1==2)
{
int call3=menue4();
if(call3==1)
{
menue3(call3);
}
else if(call3==2)
{
menue3(call3);
}


}
}
}

//
Have you covered structs or arrays?
What if you need to handle 10 products? 100 products?
You going to find it very tedious to write input and output functions for every product.

This would be a lot easier if you created an array of structs to hold information about your products.
1
2
3
4
5
6
7
8
9
10
11
struct Product    /* first define the struct */
{  int UPC; 
    int quantity; 
    string man; 
    string prodname;
    double price;
    int tValue;
};

const int MAX_PRODUCTS = 2;
Product products[MAX_PRODUCTS];  /* An array of Product */


Now, you can write a single function that prompts for one product and also write a display function that displays one product. Use a loop to call the entry routine multiple times and another loop to display each of the products in your array.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Hi thanks everyone it is for two products and no functions can be used... All inside of int main and ill start to comment EVERYTHING now. If i could have used functions it would have made with 100 times easier ):
no functions can be used

No functions? What are menue(), menue2(), and menue3() ?

ill start to comment EVERYTHING now

The request to use code tags did not refer to commenting your code.
It referred to using the
[code]
and
[/code]
formatting tags which you used the first time you posted your code, but did not do so the second time.

abstraction the menue() isnt my post. please look clearly...
Sorry. You're right.
Topic archived. No new replies allowed.