Hey I am doing a tutorial at uni and I need to write a code that
Task 3
Write a program that accept from the command line number n and then print stars ‘*’ in n rows.
For example, if n = 5 then the program should print:
*
* *
* * *
* * * *
* * * * *
Note that you must let the user input the number for rows from the command line. For example, if the command line input is 5, you will have args[0] = "5". Then you can use
int n = Integer.parseInt(args[0]); // now n=5
here is my code so far, I have asked my tutorial teacher. All she did was pass me a pen and paper and smile and there is nothing in the lectures about how to do it. Any help, as quick as possible would be appreciated.
public class ArgsLoop {
public static void main(String[] args) {
int n = Integer.parseInt(args[0]); // now n=5
for(int i=0;r<n;i++){
System.out.println("*");
for(int c=i; c<n; c++){
System.out.print("*");
}
}
}
}