HowMany.java


Below is the syntax highlighted version of HowMany.java.


 /*********************************************************************
  *  Compilation:  javac HowMany.java
  *  Execution:    java HowMany str1 str2 ... strN
  *  
  *  HowMany takes a variable number of command-line arguments
  *  and prints a message reporting how many there are.
  * 
  *   > java HowMany
  *   You entered 0 command-line arguments.
  * 
  *   > java HowMany Alice Bob Carol
  *   You entered 3 command-line arguments.
  * 
  *   > java HowMany Alice 
  *   You entered 1 command-line argument.
  *                                              Web Exercise 1.4.1
  ********************************************************************/

 public class HowMany {

    public static void main(String[] args) {

       // number of command-line arguments
       int N = __________________________________;
 
       // output message
       System.out.print("You entered " + N + " command-line argument");
       if (__________) System.out.println(".");
       else            System.out.println("s.");
    }
 }