Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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++

image text in transcribed

#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

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_2

Step: 3

blur-text-image_3

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

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

Q.1. Health issues caused by adulteration data ?

Answered: 1 week ago

Question

1. Traditional and modern methods of preserving food Articles ?

Answered: 1 week ago

Question

What is sociology and its nature ?

Answered: 1 week ago

Question

What is liquidation ?

Answered: 1 week ago