Examine the pseudocode sample provided, and explain what it does line by line. P
ID: 3675593 • Letter: E
Question
Examine the pseudocode sample provided, and explain what it does line by line.
Program: applyDiscount
Create variable productPrice as double
Create variable discount as double
Create variable wholesalePrice as double
Create variable discountedPrice as double
productPrice = get value from user input
discount = get value from user input
wholesalePrice = get value from user input
discountedPrice = productPrice * (1 – discount)
if (discountedPrice < wholesalePrice)
discountedPrice = wholesalePrice
end if
Display discountedPrice
End program
Explanation / Answer
//Create variable productPrice as double
double productPrice;
//Create variable discount as double
double discount;
//Create variable wholesalePrice as double
double wholesalePrice
//Create variable discountedPrice as double
double discountedPrice;
productPrice = get value from user input // asking user to enter product price
discount = get value from user input // asking user for discount value
wholesalePrice = get value from user input // asking user for whole sale price
discountedPrice = productPrice * (1 – discount) // calculating price after giving discount
if (discountedPrice < wholesalePrice) // if price after discount is less than whole sale price then
// discounted price is also equal to whole sale price
discountedPrice = wholesalePrice
end if
Display discountedPrice // other wise no chage in discounted price and printing
End program
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.