-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathTableUtilities.java
More file actions
58 lines (54 loc) · 1.65 KB
/
TableUtilities.java
File metadata and controls
58 lines (54 loc) · 1.65 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
public class TableUtilities {
public static String getSmallMultiplicationTable() {
String table = "";
for (int i = 1; i <= 5; i++) {
for (int x = 1; x <= 5; x++) {
int b = i * x;
String z = String.valueOf(b);
String space = " ";
if (z.length() == 2) {
space = " ";
}
table += space + b + " |";
}
table += "\n";
}
return table;
}
public static String getLargeMultiplicationTable() {
String table = "";
for (int i = 1; i <= 10; i++) {
for (int x = 1; x <= 10; x++) {
int b = i * x;
String z = String.valueOf(b);
String space = " ";
if (z.length() == 2) {
space = " ";
} else if (z.length() == 3){
space = "";
}
table += space + b + " |";
}
table += "\n";
}
return table;
}
public static String getMultiplicationTable(int tableSize) {
String table = "";
for (int i = 1; i <= tableSize; i++) {
for (int x = 1; x <= tableSize; x++) {
int b = i * x;
String z = String.valueOf(b);
String space = " ";
if (z.length() == 2) {
space = " ";
} else if (z.length() == 3){
space = "";
}
table += space + b + " |";
}
table += "\n";
}
return table;
}
}