Write a function, computePrice that receives two parameters: the first one is a character variable indicating the size of the pizza (S, M or L) and the second an integer variable indicating the number of toppings on the pizza. It then computes the cost of the pizza and returns the cost as a floating point number according to the rules:
• Small pizza = R50 + R5.50 per topping
• Medium pizza = R70 + R6.50 per topping
• Large pizza = R90 + R7.50 per topping
I must ONLY do the function , not whole program
1 2 3 4 5 6 7 8 9 10 11 12
double Pizza::computePrice()
{
double cost = 0.0;
switch (size)
{
case SMALL:
cost += 50; break;
case MEDIUM:
cost += 70; break;
case LARGE:
cost += 90; break;
}
How do I make a certain amount for each size for topping?
Do I write this? or how?
1 2 3 4 5 6 7 8
if (SMALL)
cost += 5.5;
if (MEDIUM)
cost += 6.5;
if (LARGE)
cost += 7.50;
return cost;
}