File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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: 24187
    
  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: 4642
    
    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: 11448
    
  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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Produce Java code Output