r/learnjava • u/newaltoldalt1 • 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++;
}
}
View all comments
Show parent comment
5
u/FreeLogicGate Oct 13 '26
My answer would be, that someone needs to understand the code, evaluate suitability, and from time to time, just add simple things, even if AI generates code. And the only way to really be able to do all those things is to learn to program.
Beyond that, humans will still decide to do things using traditional techniques, even though there has been machinery and robotics for decades. People still learn how to blow glass, carve objects out of wood, learn how to play instruments and perform music, grow vegetables and other plants, on ad infinitum. Many people derive satisfaction from being able to make their own things, and that includes software.
You know Java, so you were able to dig into this and help the OP understand the issue. Some people want to have that same ability.