Help With Calculator Pl0x
I am new to java, and am attempting to learn it. So far I am trying to make a simple command prompt argument calculator, and it isnt working.
Here's my code
public class calculator
{
public static void main( String[] args)
{
int i = Integer.parseInt(args[0]) ;
int y = Integer.parseInt(args[2]) ;
String modi =(args[1]) ;
int ans = 0;
if( args.length !=3)
{
System.out.println("wrong number of arguments") ;
return;
}
if (modi=="+")
{
ans =(i + y );
System.out.println(ans) ;
}
else if (modi=="-")
{
ans = (i - y );
System.out.println(ans ) ;
}
else if (modi=="/")
{
ans = (i / y );
System.out.println(ans ) ;
}
else if (modi=="x")
{
ans = (i*y );
System.out.println(ans ) ;
}
else
{
System.out.println("Failure In Arguments") ;
}
}
}
I'm trying to use 56 x 2 for the arguments.
My guess is that I'm missing something simple, but i can't find it.
I have tried sending the arguments through the command prompt and eclipse and neither work.
Any correction would be helpful.