• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

java program  RSS feed

 
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?

 
Marshal
Posts: 67164
169
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.
 
Marshal
Posts: 61774
193
  • 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
 
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.
 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!