174k views
5 votes
The tax calculator program of the case study outputs a floating-point number that might show more than two digits of precision. Use the round function to modify the program to display at most two digits of precision in the output number.

1 Answer

4 votes

Answer:

Step-by-step explanation:

The following code is written in Python. The tax calculator program was not provided, therefore I created a tax calculator that takes in the total price as an input and adds a 7% tax to it. Then it uses the round() function to make sure that the total is outputted as a decimal with two decimal digits at most.

def taxCalculator(price):

total = price * 1.07

formattedTotal = round(total, 2)

return formattedTotal

The tax calculator program of the case study outputs a floating-point number that-example-1
User Jon Seigel
by
4.7k points