Write a program that produces the following output Use a cla
Solution
Please follow the code and comments for description :
CODE :
public class StairStick { // class that runs the code
public static final int steps = 5; // class constant for the number of steps
public static void main(String[] args) { // driver method
   
 for (int i = 0; i < steps; i++) { // iterating over the loop for the steps
 System.out.format(((steps == (i + 1)) ? \"\" : (\"%\" + ((steps - i - 1) * 5) + \"s\")) + \" o ******\" + ((i == 0) ? \"\" : (\"%\" + (i * 5) + \"s\")) + \"*\ \", \" \", \" \"); // formatting to print the head part of the man with asteriks
 System.out.format(((steps == (i + 1)) ? \"\" : (\"%\" + ((steps - i - 1) * 5) + \"s\")) + \" /|\\\\ * \" + ((i == 0) ? \"\" : (\"%\" + (i * 5) + \"s\")) + \"*\ \", \" \", \" \"); // formatting the output to print the body part of the man and asteriks
 System.out.format(((steps == (i + 1)) ? \"\" : (\"%\" + ((steps - i - 1) * 5) + \"s\")) + \" / \\\\ * \" + ((i == 0) ? \"\" : (\"%\" + (i * 5) + \"s\")) + \"*\ \", \" \", \" \"); // formatting the output to print the lowe body part of the man and asteriks
 }
 for (int j = 0; j < (steps + 1) * 5 + 2; j++) { // for the rest of the loop printing the asteriks to build a stair case
 System.out.print(\"*\"); // printing the asteriks
 }
 System.out.println(\"\ \"); // end of the line
 }
 }
OUTPUT :
o *******
 /|\\ * *
 / \\ * *
 o ****** *
 /|\\ * *
 / \\ * *
 o ****** *
 /|\\ * *
 / \\ * *
 o ****** *
 /|\\ * *
 / \\ * *
 o ****** *
 /|\\ * *
 / \\ * *
 ********************************
 Hope this is helpful.

