Question: do part 2 in c++ #include #include #include using namespace std; class Ingredient { private: string name; float unitPrice; int amount; public: Ingredient() { }

do part 2 in c++

do part 2 in c++ #include #include #include using namespace std; class

#include

#include

#include

using namespace std;

class Ingredient {

private:

string name;

float unitPrice;

int amount;

public:

Ingredient() {

}

Ingredient(string name, float unitPrice, int amount) {

this->name = name;

this->unitPrice = unitPrice;

this->amount = amount;

}

string getName() {

return this->name;

}

float getUnitPrice() {

return this->unitPrice;

}

int getAmount() {

return this->amount;

}

void setUnitPrice(int unitPrice) {

this->unitPrice = unitPrice;

}

void print() {

cout name

unitPrice

amount

}

};

float calculateCost(Ingredient*, int);

Ingredient* applyDiscount(Ingredient*, float, int);

bool canCook(vector, vector);

int main() {

return 0;

}

// Calculate the cost of the shopping list corresponding to each ingredient's

// -- unitPrice and amount

float calculateCost(Ingredient *shoppingList, int size) {

// *** FILL THIS FUNCTION FOR PART 1 ***

float cost = 0.0;

// iterate regards to size

for(int i = 0; i

cost += (shoppingList[i].getUnitPrice() * shoppingList[i].getAmount());

}

return cost;

}

// Apply the discount for the ingredient's in the shopping list

// -- The discount rate is in 0

Ingredient* applyDiscount(Ingredient *shoppingList, float discount, int size) {

// *** FILL THIS FUNCTION FOR PART 2 **

}

// Check whether the cook recipe is given can be cooked by the ingredients

// -- in the fridge

bool canCook(vector recipe, vector fridge) {

// *** FILL THIS FUNCTION FOR PART 3 ***

}

Part II (40 point) a Write a function that applies discount on the shopping list given by pointers. Assume that 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!