-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern_t6.java.bak
More file actions
25 lines (23 loc) · 811 Bytes
/
pattern_t6.java.bak
File metadata and controls
25 lines (23 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;
class Pattern_t6
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of rows: ");
int n = sc.nextInt();
for (int i = 0; i < n; i++) { // Start i from 0
for (int j = 0; j < n; j++) { // j < n
if (j == n - i - 1||i==n-1) {
// Print left edge of the pyramid
System.out.print("*");
} else if (j == n - 1) {
// Print the right edge of the pyramid for the last row
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println(); // Move to the next line
}
}
}