java - Printing Stars based on input from Command Prompt -
I have been assigned a project to print the pattern of stars with bee, we are assuming that the number given in the CMD And it will print a pattern. Or at least this is how I understand it.
What the assignment says:
Take a numerical input from the command line and produce the correct number of wires and rows.
Example:
C: \ Java will generate stars 3
,
* * * ***
So far my code is:
public square stars 1 int len = args. Length; If (lane and lt; = 0) {System.out.println ("Error: input value of 1-5"); System.exit (0); } At Jay; For (int i = 0; i & lt; = 4; i ++) {for (j = 0; j & lt; = i; j ++) System.out.print ("*"); Println (""); }}}
I am trying to create a pattern:
* ** *** **** *****
The example code he showed us was used to type args.length using the command prompt at any time. So if we type in the C: \ Java Echo I type, then type it.
This will type I type, this type.
This is the code he asked us to look for:
public class echo {public static zero sopl (string str) {System.out.println ( "\ T" + str); } Public static zero (string str) {System.out.print (str); } Public static zero main (string [] args) {int len = args.length; If (lane == 0) {soap ("\ n \ tUsage: java echo and lt; args: string []> gt;"); System.exit (0); } Soap ("\ n \ t"); For (int i = 0; i gt) soap (rg [args.length - len--] + ""); Soap (""); }
How do I use args.length to create patterns? I can easily produce patterns without taking the input pattern to the command line.
Comments
Post a Comment