-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRhombusOfStars.java
42 lines (29 loc) · 958 Bytes
/
RhombusOfStars.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
37
38
39
40
41
42
package Abstraction;
import java.util.Scanner;
public class RhombusOfStars {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = Integer.parseInt(scan.nextLine());//3
String symbol = "";
for (int row = 1; row <= n; row++) {
printRow(n," ", row);
printRow(row,"* ");
System.out.println();
}
for (int row = 1; row <= n - 1 ; row++) {
printRow(row," ");
printRow (n,"* ",row);
System.out.println();
}
}
private static void printRow (int n, String symbol,int row) {
for (int col = 0; col < n - row; col++) {
System.out.print(symbol);
}
}
private static void printRow (int row, String symbol){
for (int col = 0; col < row; col++) {
System.out.print(symbol);
}
}
}