
create an exception class, which thros an exception if operand is non-numeric in claculating modules. ( Use command line arguments)

public class Calculator{
public static void main(String[] args){
//Enter expression as 'a + b'
int result = 0;
switch(args[1].charAt(0)){
case '+': result = Integer.parseInt(args[0]) + Integer.parseInt(args[2]);
break;
case '-': result = Integer.parseInt(args[0]) - Integer.parseInt(args[2]);
break;
case '*': result = Integer.parseInt(args[0]) * Integer.parseInt(args[2]);
break;
case '/': result = Integer.parseInt(args[0]) / Integer.parseInt(args[2]);
}
System.out.println(args[0] + ' ' + args[1] + ' ' + args[2] + " = " + result);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.