Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you find the reason that the following pseudocode function does not return t

ID: 3762216 • Letter: C

Question

Can you find the reason that the following pseudocode function does not return the value indicated in the comments? // The calcDiscountPrice 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 calcDiscountPrice(Real price, Real percentage) // Calculate 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

Explanation / Answer

Function Real calcDiscountPrice(Real price, Real percentage) // Calculate the discount.

Declare Real discount= (price * percentage) / 100.0 // Subtract the discount from the price.

//dividing by 100.0 because of % concept

Declare Real discountPrice = price - discount // Return the discount price.

Return discount End Function

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote