Can't passed by the Hidden TestCase #3 and #4 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Can't passed by the Hidden TestCase #3 and #4

https://www.sololearn.com/coach/22?ref=app // I've done following code in Java for the above codeCoach. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int colors = sc.nextInt(); int colorsCost = colors *5; int projectCost = colorsCost +40; int storeTax = projectCost *10/100; int totalCost = storeTax +projectCost; System.out.println(totalCost); } }

30th Jul 2021, 6:52 PM
M Zulqarnain Khan
M Zulqarnain Khan - avatar
2 Answers
+ 1
use double instead of int for variables since a division is used. then round up the result and output an int. System.out.println((int)Math.ceil(totalCost)); Math.ceil() to round up (int) to cast double to int.
30th Jul 2021, 7:11 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
I've no approach in math.ciel yet.
30th Jul 2021, 7:18 PM
M Zulqarnain Khan
M Zulqarnain Khan - avatar