+ 1
Help Code Coach - Paint cost ( easy level )
This is the question You are getting ready to paint a piece of art. The canvas and brushes that you want to use will cost 40.00. Each color of paint that you buy is an additional 5.00. Determine how much money you will need based on the number of colors that you want to buy if tax at this store is 10%. I have written my code but it keeps saying try again. Even the output expected is the same as my output. Here is my code https://code.sololearn.com/c4dujEBtLAGQ/?ref=app
3 Respuestas
+ 3
The issue is in rounding up.
you just converted double to int. that's not rounding up.
rounding up always gets the next whole number.
3.1 rounded up = 4
3.8 rounded up = 4
delete the conversion
and use Math.ceil(),
(int) is just there to get rid of decimal point.
// converts sum to integer
// int finaleCost = (int) sum;
System.out.println((int)Math.ceil(sum));
+ 2
Thanks for the help