alright ive been banging my head against a wall for three hours and i give up does anyone have a clue? the what im supposed to do is write a method named lotsOfStars that will accept two integers: the first integer indicates
the number of lines to print, the second the number of asterisks per line. The method should
print a rectangular arrangement of asterisks.

such as 3,4
****
****
****

Recommended Answers

All 5 Replies

Hints:

for (the number of lines you are given to print){
-print a newline.
for (the number of asteriks per line){
-print one asterik. Do not print a newline.
}


You can do printing using System.out.println and System.out.print. The former will print a newline (same as hitting enter basically) and the latter will not print a newline.
}

Indeed there must be the problem in using System.out.println instead of System.out.print in the inner loop.

Indeed there must be the problem in using System.out.println instead of System.out.print in the inner loop.

WHAT??

Indeed there must be the problem in using System.out.println instead of System.out.print in the inner loop.

What went wrong? I tried to guess the mistake the programmer (icke2433) might be making.

public static void lotsOfStars(int lines, int stars) {
        for (int i = 0; i < lines; i++) {
            for (int j = 0; j < stars; j++) {
                System.out.print("*");
            }
            System.out.print("\n");

        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.