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!"); } } }

3rd Dec 2016, 11:12 AM
Sourav Giri
Sourav Giri - avatar
3 Respuestas
+ 2
1) Change "double ar = in.nextInt();" to "double ar = in.nextDouble();" 2) make sure you write your "Math.round()" methods properly.
3rd Dec 2016, 11:53 AM
Ousmane Diaw
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.
3rd Dec 2016, 12:36 PM
Surya Konduru
Surya Konduru - avatar
0
Thanks.
4th Dec 2016, 4:29 AM
Sourav Giri
Sourav Giri - avatar