Answer to Question #341789 in C++ for LM.

Question #341789

(iv) 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


1
Expert's answer
2022-05-18T15:26:33-0400
float computePrice(char size, int amountToppings){
    switch(size){
        case 'S': return 50 + 5.50*amountToppings;
        case 'M': return 70 + 6.50*amountToppings;
        case 'L': return 90 + 7.50*amountToppings;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS