-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
36 lines (26 loc) · 873 Bytes
/
Main.java
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
26
27
28
29
30
31
32
33
34
35
36
import java.util.Scanner;
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Prompt user for a step for the pattern
System.out.print("Enter a step for the pattern: ");
int step = scanner.nextInt();
// Display the result
for (int i = step; i > 0; i--) {
int diff = step - i;
for (int j = 0; j < diff; j++) {
System.out.print(" ");
}
for (int j = 0; j < i; j++) {
System.out.print("*");
}
for (int j = 0; j < i - 1; j++) {
System.out.print("*");
}
System.out.println();
}
// Close the scanner
scanner.close();
}
}