class Hitung
{
public static void main(String[] args)
{
int op1=0,op2=0,h=0;
if (args.length!=3)
{
System.out.println("perlu 3 argumen; arg1=operan1,arg2=operan2, arg3=operator");
System.out.println("arg3=1: +;arg3=2: -;arg3=3:*");
System.out.println("Contoh java hitung 2 3 1: artinya:2+3");
}
else
{//3 argumen
op1=Integer.parseInt(args[0]);//arg-1
op2=Integer.parseInt(args[1]);//arg-2
if (args[2].equals("1")){h=op1+op2;}
else if (args[2].equals("2")){h=op1-op2;}
else if (args[2].equals("3")){h=op1*op2;}
System.out.println("hasil:"+h);
}
}
}
Sunday, 19 January 2014
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment