TableUtilities.java 917B

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