I wrote this code to implement a cmd line arg calc in Java. It it not running. Please help.
I run the program from Eclipse : arguments I pass are 12 + 13 . 3 arguments arg0 is first value, arg 1 is symbol to perform calculation and arg2 is second value.. Here goes the code...
public class CommandLine {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String s2 = args[1];
char ch = s2.charAt(0);
int i,j,total;
i = Integer.parseInt(args[0]);
j = Integer.parseInt(args[2]);
switch(ch)
{
case '+' :
total = i + j;
break;
case '*' :
total = i *j;
System.out.println("Multiply");
break;
// other symbols to be included later...
}
System.out.println(args[0] + ch + args[2] + " " + total);
}
}


Sign In
Create Account

Back to top









