fork download
  1. Integer height = 5; // Number of rows
  2. // Loop for each row
  3. for (Integer i = 0; i < height; i++) {
  4. String row = '';
  5. // Loop for each column (7 columns)
  6. for (Integer j = 0; j < 7; j++) {
  7. // Place stars for the "M" shape
  8. if (j == 0 || j == 6) {
  9. row += '*'; // Stars for the sides
  10. } else if ((i == j && j <= 3) || (i + j == 6 && j >= 3)) {
  11. row += '*'; // Stars for the middle diagonals
  12. } else {
  13. row += ' '; // Spaces everywhere else
  14. }
  15. }
  16. System.debug(row); // Print the row
  17. }
Success #stdin #stdout #stderr 0.01s 8944KB
stdin
Standard input is empty
stdout
Object: Integer error: did not understand #height
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
Integer class(Object)>>doesNotUnderstand: #height (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
stderr
./prog:2: expected expression