Results 1 to 7 of 7
Thread: Inverted Right Triangle help
- 07-29-2010, 03:18 AM #1
Member
- Join Date
- Jul 2010
- Posts
- 4
- Rep Power
- 0
Inverted Right Triangle help
I have the code:
and the output is:Java Code:public class InvertedRightTri { public static void main(String[] args) { int a=1; int b; int c=5; do{ b = a - 1; if (b!=0){ do{ System.out.print(" "); b--; }while(b >= 1); } b=1; do{ System.out.print("*"); b++; }while(b <= (c - a + 1)); System.out.println(); a++; }while(a <= c); } }
need help another code for this using the do-while loop also.XML Code:***** **** *** ** *
Please help me to all experts, i need your help as soon as possible. I'm new to java.
Thanks for reply!Last edited by Eranga; 07-29-2010 at 06:41 AM. Reason: code tags added
- 07-29-2010, 06:42 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you have tried so far, show your effort here. Then we'll help you to comes out on what you've stuck.
- 07-29-2010, 01:37 PM #3
What is the problem you are trying to solve? What do you need help with?
I don't see any questions in your post.
- 07-29-2010, 01:51 PM #4
I am not sure that I've understood your question.
I may suggest that you notice the order of the loops, though.
That's probably the key, if I got your question right.
- 07-30-2010, 05:31 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
May be OP wants to do this with for loops or something. My point is whatever the way he/she is not put some effort to do something.
- 07-30-2010, 05:37 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Maybe the following little method will help:
The method prints 'n' symbols 's' on a line; the OP can now think in terms of printing symbols on a line ...Java Code:public void printymbols(char s, int n) { for (int i= 0; i < n; i++) System.out.print(s); }
kind regards,
Jos
- 07-30-2010, 06:10 PM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Could be, but the OP has no interaction since yesterday on his/her first thread in our forum. :)
Similar Threads
-
Triangle using Numbers
By Anandt88 in forum New To JavaReplies: 16Last Post: 06-05-2010, 04:10 PM -
ASCII Triangle
By physics in forum New To JavaReplies: 2Last Post: 03-13-2010, 01:00 AM -
triangle program
By computerbum in forum New To JavaReplies: 8Last Post: 03-02-2010, 04:55 AM -
Triangle
By jkswebsite in forum New To JavaReplies: 8Last Post: 01-10-2009, 02:08 PM -
Is it a right triangle? (Code help)
By TheApostle in forum New To JavaReplies: 8Last Post: 10-07-2008, 08:39 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks