In: Computer Science
Write the program in C++
The Rebel food truck has asked you to write a program for them to do both inventory and sales for their food wagon. Ben and Dave run the food truck and they already have full time day jobs so they could really use your help.
The food truck sells: hamburger, hotdogs, chilli, fries and soda. The truck has spots for 200 hamburger patties, 200 hot dogs, 75 hamburger buns, 75 hot dog buns, 500 ounces of chili, 75 fry baskets and 200 cans of soda.
Items sells for: Hamburger - $5, Hotdogs - $5, Chili (12 oz.) - $4, Fries (basket) - $7, Chili on burger, dog or fries (4 oz) - $2, Soda - $2. There is 5% tax in the area.
Create a menu driven program that they can run at the top of the night, put in current inventory and then sell items allowing them to enter sales for a customer on a repeating basis and get a result to charge them. Also take the items out of inventory when they are used. If an item goes to near zero and can no longer be sold then it should come off the menu.
Have something in the program that allows the user to terminate the program at the end of the night and it should signal to them if inventory for an item goes below 20%.
#include<iostream>
using namespace std;
int main()
{
//inititalize the items
string items[7]={"Hamburger Patties","Hamburger
Buns","Hot Dogs","Hot Dog Buns","Chilli","Fry
Baskets","Soda"};
//initialize the quantity
static int nos[7]={200,75,200,75,500,75,200};
//initialize the price
int price[7]={5,5,5,5,4,7,2};
//initialize the twenty percentage of
items
int
twentypercen[7]={40,15,40,15,100,15,40};
int i,j,k,total=0,n;
char opt;
//infinite loop
while(1)
{
//display the items
for(i=0;i<7;i++)
{//check the status of items
whether 0 or not, if 0 then discard it from menu
if(nos[i]!=0)
{
if(items[i].length()>=12 ) //condition for formatting the
output, i.e/ allow a single tab otherwise double tab
cout<<endl<<i+1<<". "<<items[i]<<" \t
"<<nos[i]<<" \t $"<<price[i];
else
cout<<endl<<i+1<<". "<<items[i]<<"
\t\t "<<nos[i]<<" \t
$"<<price[i];
}
}
//ask about the choice
cout<<endl<<"Enter your
order";
cin>>k;
//condition for chillis
if(k==5)
{
//ask for the
purpose of chilli
cout<<endl<<"Do you want chilli with burgor dog or
fries(y/n)";
cin>>opt;
if(opt=='y' ||
opt=='Y')
{
top1:
//ask for the quantity of chilli
cout<<endl<<"Enter the quantity of
"<<items[k-1];
cin>>n;
//the quantity
must be multiple of 4
if(n%4!=0)
{
cout<<endl<<items[k-1]<<"can be taken out
multiple of 4";
goto top1;
}
//compute the
total
total=total +
2*(n/4);
//update the
quantity
nos[k-1]=nos[k-1]-n;
}
else
{
top:
//ask the quantity
cout<<endl<<"Enter the quantity of
"<<items[k-1];
cin>>n;
if(n%12!=0) //it
should be multiple of 12
{
cout<<endl<<items[k-1]<<"can be taken out
multiple of 12";
goto top;
}
//compute the
total
total=total +
price[k-1]*(n/12);
//update the
quantity
nos[k-1]=nos[k-1]-n;
}
}
//block for other items
else
{
//ask for the quantity
cout<<endl<<"Enter the quantity of
"<<items[k-1];
cin>>n;
//compute the total
total=total + price[k-1]*n;
//update the quantity
nos[k-1]=nos[k-1]-n;
}
//display the
items below 20%
for(i=0;i<7;i++)
{
if(nos[i]<twentypercen[i])
cout<<endl<<items[i]<<" goes below 20%";
}
//ask user to continue or not
cout<<endl<<"Do you
want to continue(y/n)";
cin>>opt;
if(opt=='n'||opt=='N')
break;
}
//display the total
cout<<endl<<"Total Amount to pay :
$"<<total;
}
output