Results 1 to 6 of 6
- 07-14-2010, 10:32 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 3
- Rep Power
- 0
Class pattern to generate following pattern:-
How should I write a program so that it define a class pattern to generate following pattern inone program.
I mean when I compile a program it executes all the patterns in one single program.
I am new to JAVA...had been assigned this as a project work... but can't figure out how to do .PLZ help.
A. A method takes an int. argument n and print the following
a
aaa
aaaaa
aaaaaaa
aaaaa
aaa
a
B. A method takes an int. arugument n and print following
1
121
12321
1234321
12321
121
1
C. A method takes an int. arugument n and print following
1234321
123 321
12 21
1 1
D. A method takes an int. arugument n and print following
55555
54444
54333
54322
54321
- 07-14-2010, 10:46 PM #2
It looks like you'll need a loop.
What have you coded so far?
Take it one step at a time.
What is to print on the first line?
What is to print on the second line? Is there a relationship between what line you are on and what is to print on that line?
Continue until the last line.
- 07-14-2010, 10:58 PM #3
Member
- Join Date
- Jul 2010
- Posts
- 3
- Rep Power
- 0
Thanks for the quick reply....
I am still unable to get started on it..
-
Hang in there. We'll be glad to help you out as long as you understand that we won't write this for you.
Think of what logic you'd need if you were to do this on paper and then break this logic down into small steps, and then if you'd like post it here and we can go over this with you. An excellent resource to help you get started is the link in my signature titled "So you need to write a program but don't know how to start". Have a look at it as it can help you.
- 07-14-2010, 11:13 PM #5
Start with the HelloWorld program.
Add a for loop around the println() with the "Hello World" message so that it prints out each time the loop goes around.
- 07-14-2010, 11:15 PM #6
Member
- Join Date
- Jul 2010
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Pattern
By mtyoung in forum Advanced JavaReplies: 9Last Post: 04-07-2009, 02:17 AM -
Logic to generate a pattern
By vijay_2008 in forum Advanced JavaReplies: 3Last Post: 11-23-2008, 02:40 AM -
Reading pattern using Scanner class
By Java Tip in forum Java TipReplies: 0Last Post: 01-18-2008, 12:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks