Question: Question Goal: Build user - friendly error messages on exceptions. Assignment: Three variables, price, tax and discount, supposedly hold strings of digits, suitable for converting
Question
Goal: Build userfriendly error messages on exceptions.
Assignment: Three variables, price, tax and discount, supposedly hold strings of digits, suitable for converting to floats. Write code that converts them and displays the total cost price tax discount rounded to the second decimal digit. However, if any variable fails to convert, display a string "Failed to convert values: followed by the names of the variables that failed, separated by space. The variables should be sorted as price, tax and discount.
If in order the variables were Hi: the output would be Failed to convert values: price discount.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
