I'm very new in Java Programming Language.
I asked to make something like this with nested loops method:
.
"Masukan Angka" is "Input Number" in Indonesian Language. So if we input 9, it will print out 9 lines of * and the amount of * decreased for each line.
I tried it with nested loops, this is what i made :
The code is :
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Input your number: ");
int x = in.nextInt();
for (int y = x; y > 0; y--) {
for (int z = 0; z < y; z++)
System.out.print("*");
System.out.println();
}
}
How can i make it doesn't filled up with * in the line 2-7, but instead filled with blank space like the example in the first picture?
Thanks in advance.