0
When this code won't be executed (just 3 cases from 5 were correct )
5 Answers
+ 6
Sarah ,
the rounding is required because what we are rounding is the *final result*. this is a float type, because we are using a division for calculating the tax:
> if we use 5 colors the total cost will be => 71.5 without rounding
> we can also get a result, (dependent on the way how we calculate e.g. tax) like this:
using 14 colors => 121.00000000000001 without rounding.
using 15 colors => 126.49999999999999 without rounding.
so rounding makes it easy to manage the test cases by rounding up the results.
+ 5
Sarah ,
the task description says:
...
Output Format
A number that represents the cost of your purchase rounded up to the nearest whole number.
... ^^^^^^^^^^^^^
+ 4
Use ceil or round function
+ 1
Lothar
I got it, thanks a lot
0
Lothar
Ive solved it thank u
But wouldn't the number of colors be integer ,so why will we need it?