Hello Everyone,
I am having a problem with my code when deal with constants.
My problem has to be solved using only two public static final constants.
The question ask to use 6 as the number of repetition and 10 for range of numbers. I can only use for loops in my main method. They give an example where if the number of repetitions constant is set to 7 and the range constant is set to 5 the out put would look like this.
| | | | | | |
12340123401234012340123401234012340
The out put I am getting is
| | | | | | |
1234123412341234123412341234
I know I am missing a zero where the 4 end but I my main concern is that my vertical line starts off right but than as it progress the spacing is off. I have tried to adjust this but then it gets worst. Could someone look at my for loops and give me a suggestion on how to fix this.
public class NumbersOutput { public static final int REPEAT =7; public static final int NUM = 5; public static void main (String[] arges) { for (int repeat=1; repeat<=REPEAT; repeat++) { for (int space=2; space<=NUM; space++) System.out.print("*"); System.out.print("|"); } System.out.println(); for (int i=1; i<=REPEAT; i++) { for (int n=1; n<NUM; n++) { System.out.print(n); } } }
Ok I can't seem to get the vertical lines to match up to what I want either by manually typing it or copy and past it. What the line should show on the first line is that vertical lines all line up under the zero. seven times.
On the second line my vertical lines show up under the second number 1 but than go off by a few number every time it repeats. It should line up under the number 1 every time it repeats.