Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; class Order { public: void SetFoodAndQuantity(string newFood, int newQuantity); int GetQuantity() const; private: string food; int quantity; }; void Order::SetFoodAndQuantity(string

image text in transcribed

#include #include using namespace std;

class Order { public: void SetFoodAndQuantity(string newFood, int newQuantity); int GetQuantity() const; private: string food; int quantity; };

void Order::SetFoodAndQuantity(string newFood, int newQuantity) { food = newFood; quantity = newQuantity; }

int Order::GetQuantity() const { return quantity; }

class Ledger { public: void InputOrders(); int FindHighestOrderQuantity(); private: vector orderList; };

void Ledger::InputOrders() { int orderCount; unsigned int i; Order currOrder; string currFood; int currQuantity; cin >> orderCount; for (i = 0; i > currFood; cin >> currQuantity; currOrder.SetFoodAndQuantity(currFood, currQuantity); orderList.push_back(currOrder); } }

// ENTER THE MISSING PIECE OF CODE HERE AND TEST IT IN C++. DO NOT MODIFY THE REST OF THE CODE. (THANK YOU!)

int main() { Ledger ledger; ledger.InputOrders(); cout The program first reads integer orderCount from input, representing the number of pairs of inputs to be read. Each pair has a string and an integer. One Order object is created for each pair and added to vector orderList. Write the FindHighestOrderQuantity() function in the Ledger class to return the highest quantity of all the Order objects. Ex: If the input is: 4 melon 9 sausage 27 tomato 4 mushroom 3 then the output is: Highest order quantity: 27 Note: The vector has at least one element

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions