Why does this Java to generate a number multiplication table just repeat the same line? -
below java class of output should have been
>1 2 3 4 5 6 > >2 4 6 8 10 12 > >... > >6 12 18 24 30 36
but generates 6 lines of:
>2 4 6 8 10 12
why happen?
public class alterable{ public static void main(string[] args){ int i=1; while(i<=6){ printmultiples(i); i=i+1; } } public static void printmultiples(int n){ int = 1; while(i<=6){ system.out.print(2*i+" "); i=i+1; } system.out.println(""); } }
almost there, forgot user n
parameter:
public static void printmultiples(int n){ int = 1; while(i<=6){ system.out.print(n*i+" "); i=i+1; } system.out.println(""); }
Comments
Post a Comment