I'm trying to produce this pattern, and I need help with my loop statements...
-----1-----
----333----
---55555---
--7777777--
-999999999-
public static void main(String[] args) { for(int j = 1; j<=9; j=j+2) { for(int d=5;d>=1;d--) { System.out.print("-"); } for(int k=1; k<=j; k++) { System.out.print(j); } for(int d=5;d>=1;d--) { System.out.print("-"); } System.out.println(); } }
My Output so far: -----1----- -----333----- -----55555----- -----7777777----- -----999999999-----