-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiamond.java
More file actions
29 lines (27 loc) · 907 Bytes
/
Copy pathDiamond.java
File metadata and controls
29 lines (27 loc) · 907 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
26
27
28
29
package PackageIntro;
import java.util.Scanner;
public class Diamond {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("How many floors does your hotel have? ");
int floors = sc.nextInt();
for (int i = 1; i <= floors; i++) {
for (int j = 1; j <= floors - i; j++) {
System.out.print(" ");
}
for (int x = 1; x <= (2 * i - 1); x++) {
System.out.print("*");
}
System.out.println();
}
for (int i = floors - 1; i >= 1; i--) {
for (int j = 1; j <= floors - i; j++) {
System.out.print(" ");
}
for (int x = 1; x <= (2 * i - 1); x++) {
System.out.print("*");
}
System.out.println();
}
}
}