+ 1

Can anyone tell me that is wrong plz ...Java

import java.util.Scanner; public class calculater { public static void main(String[ ] args) { Scanner input=new Scanner (System .in); System .out.println ("Enter 1st num"); int a=input.nextInt(); System .out.println ("Enter 2st num"); int b=input.nextInt(); System .out.println ("Enter operation"); String op=input.next(); int z; if(op.equals("+")){ z=a+b; } if(op.equals("+")){ z=a+b; } else if(op.equals("-")){ z=a-b; } else if(op.equals("*")){ z=a*b; } else if (op.equals("/")){ z=a/b; } System .out.println ("The result is"+ z); } }

28th Dec 2020, 2:39 PM
Dark Light
Dark Light - avatar
4 Answers
+ 3
I don't think so that there is any error. Basically what errors you are getting. And yeah give an MWE https://www.sololearn.com/post/75089/?ref=app
28th Dec 2020, 2:56 PM
Krish
Krish - avatar
+ 2
Simba thanks
28th Dec 2020, 3:07 PM
Dark Light
Dark Light - avatar
+ 2
Scanner input=new Scanner (System.in); your this line has space before the dot , which gives error remove the space or copy this and paste it
28th Dec 2020, 10:22 PM
Samima Hassan
Samima Hassan - avatar