1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
-
- //StringBuilder sb = new StringBuilder();
- String str="";
- int product = 0;
- for(int i=1;i<=5;i++)
- {
- for(int j=1; j<=5;j++)
- {
-
- product=i*j;
- str +=String.format("%3d |",product);
- }
- str +="\n";
-
- }
-
- return str;
- }
-
-
- public static String getLargeMultiplicationTable() {
- //StringBuilder sb = new StringBuilder();
- String str="";
- int product = 0;
- for(int i=1;i<=10;i++)
- {
- for(int j=1; j<=10;j++)
- {
- //sb.append(" ");
- product =i*j;
- str +=String.format("%3d |",product);
- } str +="\n";
-
- }
-
- return str;
- }
-
- public static String getMultiplicationTable(int tableSize) {
- /*StringBuilder str = new StringBuilder();
- int product = 0;
- for(int i=1;i<=tableSize;i++)
- {
- for(int j=1; j<=tableSize;j++)
- {
-
- product =i*j;
- str +=String.format("%3d |",product);
-
- } str +="\n";
- System.out.println ("Final triangle String for input - " + " \n " + sb.toString());
- return str;*/
-
- String str="";
- int product=0;
- for(int i=1;i<=tableSize;i++)
- {
- for(int j=1; j<=tableSize;j++)
- {
-
- product=i*j;
- str +=String.format("%3d |",product);
-
- } str +="\n";
- }return str;
- }
- }
|