Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1 What demand is and what affects it.

Answered: 1 week ago