File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java program" Watch "java program" New topic

java program

sahan thinusha

Joined: Nov 10, 2012
Posts: 10

please give me program for output as following * pattern using 2 for loops & only use one star?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

You need to read DoYourOwnHomework and NotACodeMill.

[Asking smart questions] [About Bear] [Books by Bear]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46349
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

Joined: Nov 10, 2012
Posts: 10

this program output is
now,how I change program to print output like this
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

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

Joined: Nov 21, 2011
Posts: 40
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.
I agree. Here's the link:
subject: java program
It's not a secret anymore!