lemonade stand inventory function

Hello, I need help with this one assignment. I'm not sure how to go any further with it. Pleas help, thank you.


assignment:
A lemonade stand needs to purchase supplies in order to do business. This stand has money (double), and keeps a stock of lemons (int), cups (int), sugar (int) and ice (int). Write a function that takes these five variables as parameters by reference and allows the owner of the stand to purchase new stock. The function should allow the owner to specify which item they wish to purchase, how many of the items they wish to purchase and should loop until they choose to quit.


My code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void LemonadeStand(double& money, int& lemons, int& cups, int& sugar, int& ice)
{
	while(keepBuying='y')
	{
		cout<<"welcome to the lemonade inventory center, you have $100.00 to spend."<<endl;    
    	cout<<"What would you like to buy?"<<endl;
    
		cout<<"1.Sugar"<<endl;
    	cout<<"2.Ice"<<endl;
    	cout<<"3.Cups"<<endl;
    	cout<<"4.Lemons"<<endl;
        cout<<"How many bags of sugar do you want?"<<endl;
    	cin>>sugar;
	}
}
Ask the user to enter 1, 2, 3 or 4. The switch the entered variable (same could be done with multiple if else statements). For each case ask "How much ... do you want", get the number into a seperate variable, then check if the user has money for it. If he does, subtract amount*price from money and add amount to lemons, cups, sugar or ice.
Topic archived. No new replies allowed.