Computer Science – Programming concepts | e-Consult
Programming concepts (1 questions)
Login to see all questions.
Click on a question to view the answer
Answer:
The program should take the original price and the amount spent as input. It needs to use nested selection statements (if-else if-else) to determine the discount based on the amount spent. The discount is applied to the original price to calculate the final price.
Here's a possible pseudocode representation:
- Get the original price (originalPrice) and the amount spent (amountSpent) from the user.
- If amountSpent > 50:
- Calculate the discount amount: discountAmount = originalPrice * 0.10
- Calculate the final price: finalPrice = originalPrice - discountAmount
- Else if amountSpent > 20:
- Calculate the discount amount: discountAmount = originalPrice * 0.05
- Calculate the final price: finalPrice = originalPrice - discountAmount
- Else:
- finalPrice = originalPrice
- Display the final price.
Example Input: Original Price = £60, Amount Spent = £55
Example Output: Final Price = £54.00