Question
JAVA PROGRAMMING Below is a completed code the prints stairs with stick figures on each step. Rewrite this code by removing the man methods and
JAVA PROGRAMMING
Below is a completed code the prints stairs with stick figures on each step. Rewrite this code by removing the "man" methods and incorporating the stick figure into one of the other methods. Do not remove the COUNT value, or do anything that will change the output of the program. Simply remove the man method and make one of the other methods draw the stick figure on each step.
CODE
public class ProgrammingAssignment1 {
public static int COUNT = 5;
public static void main(String[] args) {
man2();
}
public static void man() {
System.out.println(" 0 ******");
System.out.println("/|\\ *");
System.out.println("/ \\ *");
}
public static void print_tabs(int n) {
for (int i = n - 1; i >= 0; i--)
System.out.print("\t");
}
// prints end of stairway on extra long first line
public static void print_first_closer(int n) {
// n + 1 because base of stairs
print_closer(n + 1);
}
// prints end of stairway on normal line
public static void print_closer(int n) {
//
for (int i = COUNT - n; i >= 0; i--)
System.out.print(" ");
System.out.println("*");
}
// prints a man on a staircase
public static void man2() {
for (int i = COUNT; i > 0; --i) {
print_tabs(i);
System.out.print(" 0 *****");
print_first_closer(i);
print_tabs(i);
System.out.print("/|\\ *");
print_closer(i);
print_tabs(i);
System.out.print("/ \\ *");
print_closer(i);
}
}
}
OUTPUT (DO NOT CHANGE)
0 *******
/|\ * *
/ \ * *
0 ****** *
/|\ * *
/ \ * *
0 ****** *
/|\ * *
/ \ * *
0 ****** *
/|\ * *
/ \ * *
0 ****** *
/|\ * *
/ \ * *
0 ****** *
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started