Inventory System

Hello, Ive been working on a home inventory system for practice so i can keep track of my hobby but ive ran into 2 problems, these are the last things i need to accomplish. Heres the issue i have everything set but i cannot figure out how to subtract and add to the current inventory which is choice 3 Edit Inventory. any help on how i could go about doing this would be great. Thanks
I tried to accomplish this problem but everything i tried failed. The second problem is i dont know how to give them the option to go back to the main menu.

Last edited on
closed account (D80DSL3A)
Regarding problem 1: adjusting inventory amounts.
This means changing the value of s, s1, etc. doesn't it?
Several tasks (including this one) could be simplified if you use arrays instead of Item1 through Item5 and s through s4.

From lines 135 - 140:
1
2
3
4
cout << "How much do you want to Subtract from Item1's Supply?" << endl;
                       cin >> answer;
                               total =subInventory(s, answer );                               
                       cout << Item1 << ": " << total << endl;

Why not
1
2
3
4
cout << "How much do you want to Subtract from Item1's Supply?" << endl;
                       cin >> answer;
                              s -= answer;                               
                       cout << Item1 << ": " << s << endl;

instead?

Regarding problem 2 - going back to main menu:
Put lines 41 - 152 inside a do-while loop:
1
2
3
4
do
{
    // lines 41 - 152
}while(choice2 == 1);


Also, lines 156, 157:
1
2
else if(choice2 == 2){
    std::exit(EXIT_FAILURE);

Why is that an exit failure? Isn't this the desired means of exiting the program?
Topic archived. No new replies allowed.