Can you find the reason that the following pseudocode function does not return the value indicated in the comments?
// The setDiscountPrice function accepts an item's price and the discount percentage
// as arguments. It uses those values to calculate and return the discounted price.
Function Real setDiscountPrice(Real price, Real percentage)
// Set the discount.
Declare Real discount = price * percentage
// Subtract the discount from the price.
Declare Real discountPrice = price - discount
// Return the discount price.
Return discount
End Function
Solution
Answer
The pseudocode should
return the discountPrice not return discount
Explanation
if you observe the pseudocode
in the commment it clearly describes return the discount
price
but in the code it is mentioned
return discount
should be changed
return discountPrice
---
all the best
Get Answers For Free
Most questions answered within 1 hours.