1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
-
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- StringBuilder anw = new StringBuilder();
- int tableSize = 5;
-
- String pattern = "%4d";
- for (int i=1;i<=5;i++){
- for (int j=1;j<=5;j++){
-
- anw.append(String.format(pattern,i*j));
- }
- anw.append("\n");
- }
-
- return anw.toString();
- }
-
- public static String getLargeMultiplicationTable() {
- StringBuilder anw = new StringBuilder();
- int tableSize = 10;
- String pattern = "%4d";
- for (int i=1;i<=10;i++){
- for (int j=1;j<=10;j++){
-
- anw.append(String.format(pattern,i*j));
-
- }
- anw.append("\n");
-
- }
-
- return anw.toString();
- }
-
- public static String getMultiplicationTable(int tableSize) {
- StringBuilder anw = new StringBuilder();
- String pattern = "%4d";
- for (int i=1;i<=tableSize;i++){
- for (int j=2;j<=tableSize;i++){
- anw.append(String.format(pattern,i*j));
- }
- anw.append("\n");
-
- }
- return anw.toString();
- }
- }
|