1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- //NESTED FOR LOOPS
-
- //return String.format(" %1$2d | %2$2d |", 5, 10);
- int outputInt = 0;
- String output = "";
- for(int i = 1; i <= 5; i++){
- for(int j = 1; j <= 5; j++){
- outputInt = i * j;
- //output = output + Integer.toString(outputInt) + "|";
- output = String.format("%1$s%2$3d |", output, outputInt);
- }
- output = output + "\n";
- }
- return output;
- }
-
- public static String getLargeMultiplicationTable() {
- int outputInt = 0;
- String output = "";
- for(int i = 1; i <= 10; i++){
- for(int j = 1; j <= 10; j++){
- outputInt = i * j;
- //output = output + Integer.toString(outputInt) + "|";
- output = String.format("%1$s%2$3d |", output, outputInt);
- }
- output = output + "\n";
- }
- return output;
- }
-
- public static String getMultiplicationTable(int tableSize) {
- int outputInt = 0;
- String output = "";
- for(int i = 1; i <= tableSize; i++){
- for(int j = 1; j <= tableSize; j++){
- outputInt = i * j;
- //output = output + Integer.toString(outputInt) + "|";
- output = String.format("%1$s%2$3d |", output, outputInt);
- }
- output = output + "\n";
- }
- return output;
- }
- }
|