Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You need to implement a grocery list program in C++ The program should display a

ID: 3559616 • Letter: Y

Question

You need to implement a grocery list program in C++

The program should display a list of items and the location in the store.

The user must be able to enter the items and location in the store.

You will use a class for the items. For this assignment you will implement creating the list, adding elements, removing elements, and displaying the shopping list.

There is other information. Some people shop on a budget so they need the price and the sale price. Use an array or vector to hold the list of items.

The display should show the items by zone or location within the store. (Display the output by location.)

Summary:

Explanation / Answer

#include<iostream>
using namespace std;
const int m=20;
class dept
{ int amount[m],pris[m],k,a,b,amount1;
int code,code1,cod[m],s,last;
public:
float price,price1;
dept(void);
void sell(void);
void total_items(void);
void add_old(void);
void add_new(void);
void show(void);
};
dept:: dept(void)
{ s=0;a=10;b=40;last=5;amount[0]=0;
for(int k=0;k<last;k++)
{ s=s+1;b=b+10;
cod[k]=s;
amount[k]=a;
pris[k]=b;
}
}
void dept::add_old(void)
{ cout<<" Enter item code: ";
cin>>code1;
cout<<" Enter item price: ";
cin>>price1;
for(k=0;k<last;k++)
{ if(code1==cod[k])
{ a=a+1;
amount[k]=a;
pris[k]=price1;
}
// else
//cout<<" Sorry..This item is not available. ";
}
}
void dept::add_new(void)
{ cout<<" Enter item code:";
cin>>code1;
cout<<" Enter amount of that item: ";
cin>>amount1;
cout<<" Enter item price: ";
cin>>price1;

cod[last]=code1;
amount[last]=amount1;
pris[last]=price1;
last++;
}
void dept::show(void)
{ for(k=0;k<last;k++)
{
cout<<" CODE: "<<cod[k]<<" ";
cout<<" AMOUNT: "<<amount[k]<<" ";
cout<<" PRICE: "<<pris[k]<<endl;
}
}
void dept::sell(void)
{
cout<<" Enter product code: ";
cin>>code;
cout<<" Enter product price: ";
cin>>price;
}
void dept::total_items(void)
{
cout<<" ITEM CODE: "<<code<<" ITEM PRICE:"<<price;
}
int main()
{
dept d[10];
static int j=0;
int x,i=0,p,s=0;
  
do{

cout<<" 1. Show all stored items:";
cout<<" 2. Add an old item:";
cout<<" 3. Add a new item:";
cout<<" 4. Sell an item:";
cout<<" 5. Total sold:";
cout<<" 6. Show total items sold:";
cout<<" 7. Quit";
cout<<" ENTER YOUR CHOICE: ";

cin>>x;
switch(x)
{ case 1: d[i].show();
break;
case 2: d[i].add_old();
d[i].show();
break;
case 3: d[i].add_new();
d[i].show();
break;
case 4: d[i].sell();
i++,j++;
break;
case 5:{ cout<<"Total Sold:";
s=0;

for(p=0;p<j;p++)
{ s=s+d[p].price;
}
cout<<s;
cout<<"TK. ";
}
break;
case 6: for(i=0;i<j;i++)
{ d[i].total_items();
}
break;
case 7: break;
}
} while(x!=7);
  
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote