This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

java program

sahan thinusha
Greenhorn

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
Marshal

Joined: Jan 10, 2002
Posts: 61298
    
  66

You need to read DoYourOwnHomework and NotACodeMill.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Campbell Ritchie
Sheriff

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

Joined: Nov 10, 2012
Posts: 10


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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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.
 
GeeCON Prague 2014
 
subject: java program