In: Computer Science
Java language.
Create the following Java command line iterator application Lab4. Pass in three arguments when the program starts.
For example java Lab4 4 3 5
The command line arguments get passed into the main method as a String array in the variable object named args. Remember they get passed in as strings so you need to parse them into integers using the Integer.parseInt(args[X]) before you can treat them as integers. Create four sections that perform the following functions.
Please find the code below:
Lab4.java
package classes6;
public class Lab4 {
   public static void main(String[] args) {
       int a =
Integer.parseInt(args[0]);
       int b =
Integer.parseInt(args[1]);
       int c =
Integer.parseInt(args[2]);
       System.out.println("Printing
counting of args[0] using for loop");
       for(int
counter=1;counter<=a;counter++){
          
System.out.println(counter);
       }
       int counter=1;
       System.out.println(" Printing
counting of args[1] using while loop");
       while(counter<=b){
          
System.out.println(counter);
           counter++;
       }
       counter=1;
       System.out.println(" Printing
counting of args[2] using do-while loop");
       do{
          
System.out.println(counter);
           counter++;
       }while(counter<=c);
      
       System.out.println(" Printing args
using for each loop");
       for(String arg : args){
          
System.out.println(arg);
       }
   }
}
output:
