Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question from beginner

 
Russel Fieldhouse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q: Write a method to display filled right-hand triangles using characters. The height of the
triangle and the character used to display a triangle should be passed as method
parameters. Note that your code can only output one character at a time.

filledTriangle(4,�*�)
$$$*
$$**
$***
****


i know how to write a method to display
*
**
***
****

but cant do Qu , anyone help me???
[ May 14, 2006: Message edited by: Russel Fieldhouse ]
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you notice the pattern as you go to the next line?
 
Russel Fieldhouse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
Do you notice the pattern as you go to the next line?


yes, the pattern...i cant put the triangle "x" and "$" together
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why?
 
Russel Fieldhouse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
Why?



i just dont know how.

would you like to write such a example for me please? thx
 
Russel Fieldhouse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is what i wrote:

 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a thought to consider: as you clearly know, a "for" loop can have another "for' loop inside of it. What might not have occurred to you is that a for loop can have two or more for loops inside it, one after the other, that will execute in sequence. So, for example,

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic