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