Question: I am working on a project right now and it deals with taking an order from a customer online, maximum of 5 items per basket
I am working on a project right now and it deals with taking an order from a customer online, maximum of 5 items per basket and maximum of 7 different orders.
Below is a portion of my coding that takes order and my question was how can I edit or what can I add so that per order it will only take 5 items and maximum of 7 orders can be taken? Do I need to add bool function perhaps? Thank you for the help in advance.
Void makeOrder(inventoryItem inv[], int numberOfInvItems) { readInventory(inventory, numInvItems, lastOrdNum); lastOrdNum++; cout << " Order Number: " << lastOrdNum << endl; string name; cout << "Enter Customer name: "; getline(cin,name); displayInventory(inventory, numInvItems); displayList(inventory, numInvItems); cout << "Number of items in inventory: " << numberOfInvItems << endl; cout << "Enter item number (-1 to end): "; int itemnum, cart = 0; double CurrentTotal = 0; cin >> itemnum; while (itemnum < -1 || itemnum > 3) { cout << "Invalid entry. Enter between -1 and 3. "; cout << "Enter item number (-1 to end): "; cin >> itemnum; } while (itemnum != -1) { if (itemnum == 0) { CurrentTotal = CurrentTotal + inv[0].price; cout << inv[0].description << " added to your basket. Current Total is $" << CurrentTotal << endl; cart++; cout << "Enter item number (-1 to end): "; cin >> itemnum; } if (itemnum == 1) { CurrentTotal = CurrentTotal + inv[1].price; cout << inv[1].description << " added to your basket. Current Total is $" << CurrentTotal << endl; cart++; cout << "Enter item number (-1 to end): "; cin >> itemnum; } if (itemnum == 2) { CurrentTotal = CurrentTotal + inv[2].price; cout << inv[2].description << " added to your basket. Current Total is $" << CurrentTotal << endl; cart++; cout << "Enter item number (-1 to end): "; cin >> itemnum; } if (itemnum == 3) { CurrentTotal = CurrentTotal + inv[3].price; cout << inv[3].description << " added to your basket. Current Total is $" << CurrentTotal << endl; cart++; cout << "Enter item number (-1 to end): "; cin >> itemnum; } } if (itemnum == -1 || cart == 5) { cout << "Thank you for your order!" << endl; cout << "ORDER: " << lastOrdNum << "\t" << name << endl; } for (int i = 0; i < cart; i++) { cout << right << setw(3) << i << " " << left << setw(12) << inv[i].prodCode << " $" << right << setw(6) << fixed << setprecision(2) << inv[i].price << " " << inv[i].description << endl; } cout << "Total: $ " << CurrentTotal << " " << endl; } 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
