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

Problem: Simulate an Online Store Design a C++ program that prompt the user to b

ID: 3911398 • Letter: P

Question

Problem: Simulate an Online Store Design a C++ program that prompt the user to buy products from an online store. The program should add and remove products from the shopping cart. The user should the option to see their shopping cart. Finally, the program processes the purchase and will display a detailed receipt to the user showing the item, price, quantity and desciption. The program should be available to process discount coupons entered by the user. Program's requirements: The team will develop an online store. (Choose a store theme). For simulation purposes add items (products) to your store using arrays and files. Include price, product's description and information that you consider important to include. The user should have the option to see items at the shopping cart. . .The store can accept online coupons'codes entered by the user (online promotion) . If the user has a store reward card, the user will receive $5.00 off. In addition, if the client uses store's credit card the user will receive an additional 20% off Simulate the process of add/remove items to the cart and finally the checkout of the purchase Generate a detailed receipt to the console application and stored in a file. (Use a 10.5% of state tax and 1% of municipal tax). Include the user savings if discounts were applied. . . . Do input validations The program should be use selection and repetition structures, functions, arrays, characters and string and files as part of the solution. Those are the minimum requirements, use your imagination and creativity.

Explanation / Answer

#include <iostream>
using namespace std;

struct productdetail
{
char iteam[200];
int quatity;
double price;
}product[100];


int totProduct = 0;

void show()
{
int i;
cout<<"Iteam "<<"Quantity "<<"Price"<<endl;
for(i=0;i<totProduct;i++)
{
cout<<product[i].iteam<<" "<<product[i].quantity<<" "<<product[i].price<<endl;
}
}

void add()
{
char iteam[200];
int quant;
double Price;

cout<<"Enter Iteam Name";
cin>>itam;
cout<<"Enter Quantity";
cin>>quant;
cout<<"Enter Price";
cin>>price;

strcpy(product[totProduct].iteam,iteam);
product[totProduct].quantity = quant;
product[totProduct].price = price;
totProduct++;
}

double GetPrice(char []iName)
{
int i;
for(i=0;i<totProduct;i++)
{
if(strcmp(product[i].iteam,iName) ==0)
return product[i].price;
}
}

void Inventory(char []iName, double nQuant)
{
int i;
for(i=0;i<totProduct;i++)
{
if(strcmp(product[i].iteam,iName) ==0)
{
product[i].quantity -= nQuant;
}
}
}

void purchase()
{
int input;
int cart=0;
productdetail Cart[100];

memset(Cart,0x00,sizeof(Cart));

while(1)
{
cout<<"Want to cheout Iteam"<<endl;
cout<<"1-Yes, 0-Finish"<<endl;
cin>>input;

if(input<0 && input>1)
{
cout<<"Invalid Input. Please try Again"<<endl;
continue;
}

switch(input)
{
case :0
int i;
double Total;
double discount;
double StatTax,MTax;

cout<<"Item :"<<"Quantity :"<<"Price"<<endl;
for(i=0;i<cart;i++)
{
cout<<Cart[i].item<<Cart[i].quantity<<Cart[i].price<<endl;
Total+=Cart[i].price;
}

cout<<"Apply Promocode"<<endl;
cin>>i;
if(i==1)
cout<<"enter Promo Code"<<endl;
  
while(1)
{
cout<<"Card to Use"<<endl
cout<<"1. Reward Card"<<endl
cout<<"2. Stroe Card"<<endl
cin>>i;
if(i<0 && i>2)
{
cout<<"Invalid Input. Please try Again"<<endl;
continue;
}

if(i==1)
{
discount = (Total * 5)/100;
  
}
if(i==1)
{
discount = (Total * 20)/100;
}

Total-=discount;

cout<<"Discount "<<discount;
}

StatTax = (Total * 10.5)/100;
MTax = (Total * 1)/100;


Total = Total + StatTax + MTax;

cout<<"State Tax "<<statTax<<endl;
cout<<"Muncipality Tax "<<MTax<<endl;
cout<<"Total "<<Toatl<<endl;
break;

case:1
char iName[200];
int nQuant;
cout<<"Enter Iteam Name"<<endl;
cin>>iName;

cout<<"Enter Quantity"<<endl;
cin>>nQuant;

strcpy(Card[cart].item,iName);
Cart[cart].quantity=nQuant;
Cart[cart].price=GetPrice(iName);

Inventory(iName,nQuant);

cart++;
break;

}


}
}

int main()
{
int numb;

While(1)
{
cout<<"Welcome to Store"<<endl;
  
cout<<"1. Add Iteam to store"<<endl;
cout<<"2. Purchase"<<endl;
cout<<"3. Show Inventory"<<endl;
cout<<"4. Exit"<<endl;

cout<<"Input your choice"<<endl;
cin>>numb
if(cin<1 && cin>4)
{
cout<<"Invalid choice. Please Retry"
continue;
}

switch(numb)
{
case:1
add();
break;
case:2
purchase();
break;
case:3
show();
break;
case:4
exit();
}
}
}

Comment

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