Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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: 63426
205
  • Mark post as helpful
  • send pies
  • 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?
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!