Question: The code now works and adds a new user, I just need to save it , and when the user asks me , the new
The code now works and adds a new user, I just need to save it and when the user asks me the new one I create will let me enter the main menu normally.
int main
vector elements
ArticlePaper
ArticleFeather
ItemLaptop
ItemPencil
ArticleDraft
;
vector cart;
string inputUser, inputPass;
while true
cout "User: ;
cin inputUser;
cout "Password: ;
cin inputPass;
if User::validateUserinputUser inputPass
cout Welcome to my online store response;
if response
cout "Enter your username: ;
cin inputUser;
cout "Enter your password: ;
cin inputPass;
cout "User successfully registered.
;
continue;
internal choice;
do
cout View articles" endl;
cout View cart" endl;
cout Exit" endl;
cout "Enter your choice: ;
cin election;
change choice
Case :
int subselection;
cout View items below a certain price" endl;
cout View items above a certain price" endl;
cout Search by name" endl;
cout "Enter your choice: ;
cin subChoice;
if suboption suboption
double price limit;
cout "Enter price limit: ;
cin price limit;
cout "Available items:
;
for int i ; i elements.size; i
if subChoice && itemsigetPrice priceLimitsubChoice && itemsigetPrice priceLimit
cout i itemsigetName Price: $ itemsigetPrice endl;
else if subchoice
string element name;
cout "Enter item name: ;
cin element name;
for const self and item: items
if itemgetName item name
cout "Item: item.getName Price: $ item.getPrice endl;
char addToCart;
cout Do you want to add an item to your cart? YN: ;
cin addToCart;
if addToCart Y addToCart y
int itemNumber;
int itemQuantity;
cout "Enter item number: ;
cin itemNumber;
cout "Enter the amount: ;
cin itemQuantity;
if itemNumber && itemNumber items.size
itemsitemNumber setQuantityitemQuantity;
cart.pushbackitemsitemNumber ;
cout "Item added to cart." endl;
else
cerr "Invalid item number." endl;
string cont;
cout Do you want to exit to the main menu or continue adding items?MenuAdd: ;
cin cont;
while cont "Add"
int itemNum, qty;
cout "Enter item number: ;
cin itemNum;
cout "How many pieces?";
cin qty;
itemsitemNum setQuantityqty;
cart.pushbackitemsitemNum ;
cout "Item added to cart.
;
cout Do you want to exit to the main menu or continue adding items?MenuAdd: ;
cin cont;
break;
case :
cout "Your cart:" endl;
double total ;
for sizet i ; i cart.size; i
cout i cartigetName Price: $ cartigetPrice Quantity: cartigetQuantity endl;
total cartigetPrice cartigetQuantity;
cout "Total cost: $ total endl;
string checkout;
cout Do you want to pay or continue shopping?? PayContinue: ;
cin checkout;
if checkout "Checkout"
cout "Press Ok to close the sale..
;
string Ok;
cin Ok;
if Ok Ok
cout "Sale successfully closed. Thank you for shopping with us endl;
cart.clear;
break;
case :
cout "Goodbye!" endl;
break;
default:
cerr "Invalid choice." endl;
break;
while choice ;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
