TriangleUtilities.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. public class TriangleUtilities {
  2. public static String getRow(int numberOfStars) {
  3. String output = "";
  4. for(int i = 0; i < numberOfStars; i ++){
  5. output = output + "*";
  6. }
  7. return output;
  8. }
  9. public static String getTriangle(int numberOfRows) {
  10. String output = "";
  11. for(int i = 0; i < numberOfRows; i++){
  12. for(int j = 0; j <= i; j++){
  13. output = output + "*";
  14. }
  15. output = output + "/n";
  16. }
  17. return output;
  18. }
  19. public static String getSmallTriangle() {
  20. String output = "";
  21. for(int i = 0; i < 4; i ++){
  22. for(int j = 0; j <= i; j++){
  23. output = output + "*";
  24. }
  25. output = output + "\n";
  26. }
  27. return output;
  28. }
  29. public static String getLargeTriangle() {
  30. String output = "";
  31. for(int i = 0; i < 9; i ++){
  32. for(int j = 0; j <= i; j++){
  33. output = output + "*";
  34. }
  35. output = output + "\n";
  36. }
  37. return output;
  38. }
  39. }