TableUtilities.java 804B

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