138,011 views
45 votes
45 votes
Your boss has asked you to create a program that calculates the total cost of an item

after a discount and sales tax have been applied. You have been testing the program
using a cost of $10.00, a discount of 50%, and 10% sales tax. You know the answer
should be $5.50 but the program returns $16.50. What type of error is most likely
causing the problem?

User Geordee Naliyath
by
2.6k points

2 Answers

10 votes
10 votes

Final answer:

The type of error that is most likely causing the problem is a calculation error in the program. To calculate the total cost of an item after a discount and sales tax have been applied, you need to follow the correct order of operations. In this case, the program seems to be applying the discount and sales tax together, instead of calculating them separately.

Step-by-step explanation:

The type of error that is most likely causing the problem is a calculation error in the program.

To calculate the total cost of an item after a discount and sales tax have been applied, you need to follow the correct order of operations. First, calculate the discount by multiplying the cost by the discount rate. Then subtract the discount from the cost. Finally, calculate the sales tax by multiplying the discounted cost by the sales tax rate and add it to the discounted cost.

In this case, the program seems to be applying the discount and sales tax together, instead of calculating them separately. This results in an incorrect total cost of $16.50 instead of the expected $5.50.

User Carl Sverre
by
3.2k points
9 votes
9 votes

Answer:

Have you tried debugging the text? It shows the line by line process of the final answer

User Salep
by
3.4k points