12345678910111213141516171819202122232425262728293031323334353637383940414243 |
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- String str="";
- int table;
- for (int x=1; x<=5;x++) {
- for (int y=1; y<=5;y++) {
- table=x*y;
- str+=String.format("%4s|",table+" ");
- }
- str+="\n";
- }
- return str;
- }
-
-
- public static String getLargeMultiplicationTable() {
- String str="";
- int table;
- for (int x=1; x<=10;x++) {
- for (int y=1; y<=10;y++) {
- table=x*y;
- str+=String.format("%4s|",table+" ");
- }
- str+="\n";
- }
- return str;
- }
-
- public static String getMultiplicationTable(int tableSize) {
- String str="";
- int table;
- for (int x=1; x<=tableSize;x++) {
- for (int y=1; y<=tableSize;y++) {
- table=x*y;
- str+=String.format("%4s|",table+" ");
- }
- str+="\n";
- }
- return str;
- }
- }
|