Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
What is wrong in this code?
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);
}
}
+ 2
Salar vahidi was faster, but my corrected code is here:
https://code.sololearn.com/c767X44cG6V4/?ref=app