vendredi 7 février 2020

Trying to make 10 columns in Java for loop with if statement

I'm using a for loop in Java to make 10 columns of numbers. I'm able to generate all the numbers, but I can't get the output to be in 10 columns. Here is what I have:

    int column = 10;
    int counter = 1;
    for (int i = 100; i < 1000; i ++){
    if (i % 5 == 0 && i % 6 == 0){

        System.out.println(i + " ");
        if ((counter % column) == 0) {
            System.out.println();
            counter = 0;
        }
        counter++;
        }

Aucun commentaire:

Enregistrer un commentaire