What is wrong in this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
15th Jul 2019, 8:45 AM
Malvika Chauhan
Malvika Chauhan - avatar
2 Answers
+ 2
the only problem is Scanner user input methods(like nextInt()) are methods and must be written like this: nextInt(); you must put parentheses after their name it must be written like this: import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); int a=Math.abs(myVar.nextInt()); double b=Math.floor(myVar.nextFloat()); double c=Math.ceil(myVar.nextFloat()); System.out.println("Abs:"+a); System.out.println("Floor:"+b); System.out.println("Ceil:"+c); } }
15th Jul 2019, 9:23 AM
salar vahidi
salar vahidi - avatar
+ 2
Salar vahidi was faster, but my corrected code is here: https://code.sololearn.com/c767X44cG6V4/?ref=app
15th Jul 2019, 9:25 AM
Lennie
Lennie - avatar