0
Something went wrong in the following problem.please correct it.
import java.util.*; class Platinum { public static void main(String args[]) { Scanner in = new Scanner(System.in); double ar = in.nextInt(); if(ar>=2 && ar<=1000000000) { if(ar==2) { System.out.print(Math round(ar)); } else { System.out.print(Math. round((ar/2)+(ar/3)+(ar/4))); } } else { System.out.print("wrong!"); } } }
3 Réponses
+ 2
1) Change "double ar = in.nextInt();" to "double ar = in.nextDouble();"
2) make sure you write your "Math.round()" methods properly.
0
The above answer by @ousmane is correct the reason to do that it is you are not casting the variable properly because of which int is getting stored in double which isn't allowed in JAVA.
And, the next point is there are some syntax errors while you are calling the Math.round method because spaces between methods are not allowed in JAVA. Correct the above problems and the above code works.
0
Thanks.