• 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

Java program that reads a size and prints a triangle of that size

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this code so for but i dont know what to do from here. After the user puts a positive integer in it should post the number like this. Example use 5
1
22
333
4444
55555
After rotating 90 degrees to the right, plots a triangle:
54321
5432
543
54
5
After rotating 180 degrees to the right, plots a triangle:
55555
4444
333
22
1
After rotating 270 degrees to the right, plots a triangle:
5
45
345
2345
12345

I dont know how to put the numbers in i have the code to do it for the first triangle but the rest i do not know how they are just * in the right pattern here is my code so far.




Please help thank you.
 
Marshal
Posts: 79394
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
You should always use the code button; I have applied it to your post and you can see how much better it looks Unfortunately it highlights your incorrect indentation. If you have } as part of a line, that is bad enough, but you have got three }s in one line. Incorrectly indented code can hide errors which would be obvious in correctly indented code. Have a look at our suggestions about formatting.

Don’t even try to print out triangles in different orientations. Not yet. Start by printing one triangle. Work out on paper how to do that. Don’t even try the others until that works.
I tried your code; what is wrong with the output I saw?
 
reply
    Bookmark Topic Watch Topic
  • New Topic