0
In this code i want the outpot repeat 2 times can you help me
import java.util.Scanner; public class Main { public static void main(String[] args) { int z,n; Scanner sc= new Scanner(System.in); System.out.print("Enter N:"); n=sc.nextInt(); for(int i=0;i<n;i++) { if (i < n / 2 + 1) z = i; else z = n - i - 1; for (int j = 0; j < n / 2 - z; j++) System.out.print(" "); for (int j = 0; j < 2 * z + 1; j++) System.out.print("*"); System.out.println(""); Output= * *** ***** *** * I want this= * * *** *** ********** *** *** * *
1 Antwort
+ 1
outer (row) loop:
print spaces loop
print asterisks loop
2 * print spaces loop
print asterisks loop
println nothing