I'm having trouble figuring out how to finish this assignment. Basically, the program prompts user for first name and then outputs a menu for them to "purchase" from, user enters quantity of the product they want and totals are calculated. The items only have a limited stock and if the user tries to buy more than what is in stock, an error message is output appropriately. I am trying to figure out how to alter the menu to readout "ITEM NO LONGER AVAILABLE" after the item has been sold out.
/*
// User Input
cout<<"Please enter your first name only: ";
cin>>name1;
cout<<"Hello "<<name1<<" thank you for shopping Lisa supplements."<<endl;
cout<<"Inventory is listed below, note some items are limited:"<<endl;
// Menu Output
do
{
cout<<" Roots n' Stuff "<<endl
<<"-------------------------"<<endl
<<"1. Ginko Root($4.50)"<<endl
<<"2. Mandrake Root($1.23)"<<endl
<<"3. Ginseng Root($2.39)"<<endl
<<"4. Square Root($99.98)"<<endl
<<"5. VitaminR Root($0.78)"<<endl
<<"6. Quit "<<endl;
cout<<"Please enter the number that corresponds to your choice ";
cin>>choice;
// Calculations for purchase total
subtotal = (gin_total + man_total
+ ginse_total + sq_total + r_total);
total_post_tax = ((subtotal * TAX) + subtotal);
// Menu Options
switch(choice)
{
case 1:
cout<<USERPROMPT<<endl;
cin>>gin_quantity;
if (gin_quantity <= GIN_STOCK)
{
gin_total = (gin_quantity * GIN_COST);
}
else if (gin_quantity > GIN_STOCK)
{
cout<<"Sorry, we only have "<<GIN_STOCK<<" of those."<<endl
<<QUANTITYMAX<<GIN_STOCK<<" ginko roots."<<endl;
gin_total = (GIN_STOCK * GIN_COST);
}
break;
*/
Everything I have thus far compiles and runs as intended. I apologize for the spacing, the copy and paste skewed it.
Here is my menu and one of the cases dictating a menu choice. The format basically follows for the next 4 cases and then a 6th case representing quit and totaling the user's purchase. As I said, I'm interested in adding "item no longer available" alongside the appropriate menu output when the else statement is executed.