• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Produce Java code Output

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Murphy Tai
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know all the basics of java. I just need a code that would produce the output outlined above using loops and nested loops.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic