Results 1 to 11 of 11
Thread: need help to create this code
- 07-11-2012, 06:11 PM #1
Member
- Join Date
- Jul 2012
- Posts
- 1
- Rep Power
- 0
need help to create this code
I need some help making some star patterns. The exact instructions are as follows:
Create separate programs to produce the following patterns:
I have to use for loops to get the patterns and I've already got (a.) but I can't seem to get the second. My first pattern's code is this:
a.)
int i,j;
for(i=4 ; i >= 1 ; i--){
for(j=1 ; j<=i ; j++)
System.out.print("*");
System.out.println();Last edited by Vineet.; 07-12-2012 at 06:07 PM.
- 07-11-2012, 06:16 PM #2
Student
- Join Date
- Jul 2012
- Location
- United States
- Posts
- 328
- Rep Power
- 9
Re: need help to create this code
If you can do it anyway you want, I would suggest using a for-loop.
- 07-11-2012, 06:19 PM #3
Member
- Join Date
- Jun 2012
- Location
- Ohio
- Posts
- 10
- Rep Power
- 0
-
Re: need help to create this code
-
Re: need help to create this code
- 07-11-2012, 06:34 PM #6
Member
- Join Date
- Jun 2012
- Location
- Ohio
- Posts
- 10
- Rep Power
- 0
- 07-11-2012, 06:34 PM #7
Student
- Join Date
- Jul 2012
- Location
- United States
- Posts
- 328
- Rep Power
- 9
- 07-11-2012, 06:54 PM #8
Member
- Join Date
- Jun 2012
- Location
- Ohio
- Posts
- 10
- Rep Power
- 0
- 07-11-2012, 07:01 PM #9
Student
- Join Date
- Jul 2012
- Location
- United States
- Posts
- 328
- Rep Power
- 9
Re: need help to create this code
Well for 1, String.concat() simply returns a new String with the argument at the end. The original String remains unchanged. In order to change the original String, you would have to do something like:
Java Code:pat = pat.concat("*");
Java Code:pat += "*";
Java Code:* ** *** ****
Last edited by awinston; 07-11-2012 at 07:03 PM. Reason: Grammar
- 07-11-2012, 07:12 PM #10
Member
- Join Date
- Jun 2012
- Location
- Ohio
- Posts
- 10
- Rep Power
- 0
- 07-11-2012, 07:16 PM #11
Student
- Join Date
- Jul 2012
- Location
- United States
- Posts
- 328
- Rep Power
- 9
Similar Threads
-
code to create a folder in java
By radhika123 in forum New To JavaReplies: 7Last Post: 07-21-2011, 12:21 PM -
Create interface from my code
By Lyricid in forum AWT / SwingReplies: 1Last Post: 11-18-2009, 06:39 PM -
Trying to create a code for queue, complex stuff...
By Mikey_S in forum Threads and SynchronizationReplies: 3Last Post: 09-28-2009, 10:13 PM -
How to create directory through Java Code
By Java Tip in forum java.ioReplies: 1Last Post: 04-14-2009, 04:34 PM -
Creating a java gui to create xml code
By Jman in forum New To JavaReplies: 3Last Post: 04-27-2008, 07:56 PM
Bookmarks