This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Produce Java code Output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Produce Java code Output" Watch "Produce Java code Output" New topic
Author

Produce Java code Output

Murphy Tai
Greenhorn

Joined: Nov 26, 2009
Posts: 6
Could someone [explain to me how to write] a code that accepts a size from the user and produces a diagonal output. Like so:

Output Console:
Size? 17
$$$*$$$*$$$*$$$*$
$$*$$$*$$$*$$$*$$
$*$$$*$$$*$$$*$$$
*$$$*$$$*$$$*$$$*
$$$*$$$*$$$*$$$*$
$$*$$$*$$$*$$$*$$
$*$$$*$$$*$$$*$$$
*$$$*$$$*$$$*$$$*
$$$*$$$*$$$*$$$*$
$$*$$$*$$$*$$$*$$
$*$$$*$$$*$$$*$$$
*$$$*$$$*$$$*$$$*
$$$*$$$*$$$*$$$*$
$$*$$$*$$$*$$$*$$
$*$$$*$$$*$$$*$$$
*$$$*$$$*$$$*$$$*
$$$*$$$*$$$*$$$*$

See the pattern.
Where '17' is the user input. Any integer can be entered into program to generate a diagonal-like output of dollar signs and asterisks.

[EFH: Translated into grownup language.]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,

Welcome to JavaRanch!

What have you got so far? Do you know how to write and compile a class? How to accept arguments on the command line? Print output?


[Jess in Action][AskingGoodQuestions]
Murphy Tai
Greenhorn

Joined: Nov 26, 2009
Posts: 6
I know all the basics of java. I just need a code that would produce the output outlined above using loops and nested loops.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Murphy Tai wrote:I know all the basics of java. I just need a code that would produce the output outlined above using loops and nested loops.

Um, this is a forum, NotACodeMill. ShowSomeEffort and ask a more specific question when you get stuck.

Recommended reading: http://catb.org/~esr/faqs/smart-questions.html


luck, db
There are no new questions, but there may be new answers.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11168
    
  16

Try describing what you want to see in words. For example:

We should end up with 20 lines totals.
We should see 20 '*' characters on the first line, 19 on the second, 18 on the third.
After every third '*', print the current time in miliseconds

Once you can do that, you start translating it into code.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Produce Java code Output
 
Similar Threads
how to return items from an array to be printed diagonal
Monitor Size
Help with method
how to return items from an array to be printed diagonal
how can I disable cells in a table for selection?