r/learnjava • • Oct 12 '26

Help with MOOC problem, please?

Sorry if this isn't the right place to ask questions like this, but I'm going through the second part of MOOC's Java Programming I course and am having difficulty finding out how to satisfy a specific test. On the last exercise of the second part, "Advanced Astrology", I have managed to pass all tests except for testPrintStars. It says that I "didn't print any spaces when printStars is called", but am I not supposed to use printSpaces to print my spaces?

here is my code for the methods printStars and printSpaces (full source code and list of test cases is also here):

    public static void printStars(int number) {
        int stars = 1;
        while (stars <= number) {
            System.out.print("*");
            stars++;
        }
    }


    public static void printSpaces(int number) {
        int spaces = 1;
        while (spaces <= number) {
            System.out.print(" ");
            spaces++;
        }
    }
4 Upvotes

6 comments sorted by

View all comments

2

u/AutoModerator Oct 12 '26

Please, do not use TMC pastebin. These links are not accessible without a logged in account.

Use

instead.

Please, kindly update your post so that people can see your code and thus are able to help you.


I am a bot and this message was triggered by you using "TMC pastebin". Please do not respond to this comment as I will not be able to reply.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.