Trying to form a half triangle using a for loop, nothing is printing out

Viewed 198

This is a practice exam question I was given to study for my java exam approaching...I was given the main method and cannot change the input, only alter the two other methods and their code. I need to print out

     &
    &&
   &&&
  &&&&
 &&&&&
&&&&&&

I think I have written my for loop wrong to create the blank spaces, I cannot seem to get this write with the main method I have been give, any ideas?

public static void main(String[] args) {
    int size = 6;
    char c = '&';
    for (int i = 1; i < size + 1; i++) {
        drawBlanks(size, size - i);
        drawChars(size, size - i, c);
        System.out.println();
    }
    System.out.println();

}

public static void drawChars(int size, int i, char c) {

    for (int j = size; j < 1; j--) {
        System.out.print(c);
    }

}

public static void drawBlanks(int size, int i) {

    for (int k = 0; k <= i; k++) {
        System.out.print(" ");
    }
}
3 Answers
Related