Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java program

 
sahan thinusha
Greenhorn
Posts: 10
Android Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please give me program for output as following * pattern using 2 for loops & only use one star?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to read DoYourOwnHomework and NotACodeMill.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50221
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

As people have said, you will have to show what you have done so far. By the way, for code you should always use code tags. They work for what you posted, too; you can see the spaces appear in the right places now I have added the tags.
 
sahan thinusha
Greenhorn
Posts: 10
Android Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

this program output is
******
******
******
******
******
******
now,how I change program to print output like this
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you read the links that Bear posted, and also the ShowSomeEffort(←click) link, you'll see that folks here aren't going to just hand you the answer. So take your best shot, and come back with specific questions if you get stuck.

Here's a very important tip though: Don't write a single line of code until you've written down very clear, precise, simple steps in English (or whatever your native language may be) describing how to do the process without regard to any programming language.
 
Len Padson
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ask yourself questions like,

How does the number of the empty space and the number of the line its on correlate?

If you can find a correlation, then you could use an if statement to determine whether to print an asterisk or not.

That should get you started, but if you tinker with that for awhile (remember, ShowSomeEffort) and can't figure it out, let us know what you've done and we can help further.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic