1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. public class TableUtilities {
  2. public static String getSmallMultiplicationTable() {
  3. String multTable = "";
  4. int sum;
  5. for (int j = 1; j <= 5; j++){
  6. for (int i = 1; i <= 5; i++){
  7. multTable += String.format("%3d |", i*j);
  8. }
  9. multTable += "\n";
  10. }
  11. System.out.print(multTable);
  12. return multTable;
  13. }
  14. public static String getLargeMultiplicationTable() {
  15. String multTable = "";
  16. for (int j = 1; j <= 10; j++){
  17. for (int i = 1; i <= 10; i++){
  18. multTable += String.format("%3d |", i*j);
  19. }
  20. multTable += "\n";
  21. }
  22. System.out.print(multTable);
  23. return multTable;
  24. }
  25. public static String getMultiplicationTable(int tableSize) {
  26. String multTable = "";
  27. for (int j = 1; j <= tableSize; j++){
  28. for (int i = 1; i <= tableSize; i++){
  29. multTable += String.format("%3d |", i*j);
  30. }
  31. multTable += "\n";
  32. }
  33. System.out.print(multTable);
  34. return multTable;
  35. }
  36. }