lajdlksadlmla
[rmh3093.git] / lab4 / SumArgs.java
blobac7d294974d1d6036f0de7d818446dd01f1f9e77
1 /*
2 * SumArgs.java
4 * Version:
5 * $Id: SumArgs.java,v 1.1 2008/04/03 16:21:06 rmh3093 Exp rmh3093 $
7 * Revisions:
8 * $Log: SumArgs.java,v $
9 * Revision 1.1 2008/04/03 16:21:06 rmh3093
10 * Initial revision
14 /**
15 * @author rmh3093
18 public class SumArgs {
20 /**
21 * Sum up all integer command line arguments
23 * @param args Integers to sum
25 public static void main(String[] args) {
27 int sum = 0;
29 for (String s : args) {
30 try {
31 sum += Integer.parseInt(s);
32 } catch (NumberFormatException e) {
33 System.err.printf("Bad integer: For input string: \"%s\"\n",s);
37 System.out.printf("The sum of the arguments is: %d\n", sum);