-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathTriangleUtilities.java
More file actions
47 lines (34 loc) · 961 Bytes
/
TriangleUtilities.java
File metadata and controls
47 lines (34 loc) · 961 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public class TriangleUtilities {
public static String getRow(int numberOfStars) {
String count = "";
for (int i = 0; i < numberOfStars; i++) {
count = count + "*";
}
return count;
}
public static String getTriangle(int numberOfRows) {
String count = "";
for (int i = 1; i <= numberOfRows; i++) {
for(int j = i; j > 0; j--) {
count = count + "*";
}
count = count + "\n";
}
return count;
}
public static String getSmallTriangle() {
String count = "";
for (int i = 0; i <= 4; i++) {
for (int j = 1; j <= i; j++) {
// column is less than equal to row
count = count + "*";
}
count = count + "\n";
return getTriangle(4);
}
return count;
}
public static String getLargeTriangle() {
return getTriangle(9);
}
}