+ 1
Java Error Please help my friends !!!
My editor is showing my code as can't be compiled. Please check the error in my code. import java.util.Scanner; class Find{ public static void main(String[]args){ Scanner query = new Scanner(System.in); int inp1= query.nextInt(); int inp2=query.nextInt(); int add = inp1 + inp2; System.out.println("Sum = "+ add); if(inp1>inp2){ System.out.printlns("Substraction = "+inp1 - inp2); }else{ System.out.println("Substraction = "+inp2 - inp1); }
3 Respuestas
+ 9
// missing brackets, parentheses.
// syntax errors
import java.util.Scanner;
import java.lang.Math;
class Find {
public static void main(String[] args){
Scanner query = new Scanner(System.in);
int inp1= query.nextInt();
int inp2= query.nextInt();
int add = inp1 + inp2;
System.out.println("Sum = "+ add);
System.out.println("Substraction = "+ Math.abs(inp1 - inp2));
}
}
+ 1
Try parantheses with your operations.
In every if block, you have a string to which you add an Integer. Fine. Then you perform a mathematical operation on the string. That doesn't work.
0
Thank you so very much everyone.