-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathTableUtilities.java
More file actions
31 lines (27 loc) · 883 Bytes
/
TableUtilities.java
File metadata and controls
31 lines (27 loc) · 883 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
public class TableUtilities {
public static String getSmallMultiplicationTable() {
return TableUtilities.getMultiplicationTable(5);
}
public static String getLargeMultiplicationTable() {
return TableUtilities.getMultiplicationTable(10);
}
public static String getMultiplicationTable(int tableSize) {
String MultiTable = "";
for (Integer i = 0; i < tableSize; i++) {
String RowOfNum = "";
Integer n = 0;
for(Integer j = 0; j < tableSize; j++){
n = n + (i+1);
if(n < 10) {
RowOfNum += " " + n + " |";
} else if (n > 9 && n < 100) {
RowOfNum += " " + n + " |";
} else {
RowOfNum += n + " |";
}
}
MultiTable += RowOfNum + "\n";
}
return MultiTable;
}
}