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.