1  public class ValueOfDemo {
 2    public static void main(String[] args) {
 3
 4      //this program requires two arguments on the command line
 5      if (args.length == 2) {
 6
 7        //convert strings to numbers
 8        float a = Float.valueOf(args[0]).floatValue();
 9        float b = Float.valueOf(args[1]).floatValue();
10
11        //do some arithmetic
12        System.out.println("a + b = " + (a + b) );
13        System.out.println("a - b = " + (a - b) );
14        System.out.println("a * b = " + (a * b) );
15        System.out.println("a / b = " + (a / b) );
16        System.out.println("a % b = " + (a % b) );
17      } else {
18        System.out.println("This program requires two command-line arguments.");
19      }
20    }
21  }

Generated with vim2html
Copyright © 2003-2004 by Chip Cuccio <http://norlug.org/~chipster/finger>