
2.24 Object-oriented Programming with Java
6. int num2 = Integer.parseInt(args[1]);
7. int ch = Integer.parseInt(args[2]);
8. int result;
9. if (ch==1)
10. result=num1+num2;
11. else
12. //subtract
13. result=num1-num2;
14. //display result
15. JOptionPane.showMessageDialog(null,”The result is “+result,
”Answer”,JOptionPane.PLAIN_MESSAGE);
16. // return i.e exit programme
17. System.exit(0);
18. }
19. } // end Calculator prog
Compile Calculator2.java using the command.
C:\OopsJava\examples\src\com\oops\chap1>javac -d
c:\Oopsjava\examples\bin Calculator2.java
Now go to bin directory and type the command to execute Java program giving full package
path with ...