-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathTriangleUtilities.java
More file actions
45 lines (33 loc) · 992 Bytes
/
TriangleUtilities.java
File metadata and controls
45 lines (33 loc) · 992 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 outcome = "";
for (int i = 0; i < numberOfStars; i++) {
outcome += "*";
}
return outcome;
}
public static String getTriangle(int numberOfRows) {
String outcome = "";
String stars = "*";
for (int i = 1; i <= numberOfRows; i++) {
outcome += stars.repeat(i) + "\n";
}
return outcome;
}
public static String getSmallTriangle() {
String outcome = "";
String stars = "*";
for (int i = 1; i <= 4; i++) {
outcome += stars.repeat(i) + "\n";
}
return outcome;
}
public static String getLargeTriangle() {
String outcome = "";
String stars = "*";
for (int i = 1; i <= 9; i++) {
outcome += stars.repeat(i) + "\n";
}
return outcome;
}
}