KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
You've probably seen it before in a Java 1 class: it's a problem that asks you write a program that draws the following figure: I have to use a constant. I am not allowed to use anything but for-loops, print , and println . No parameters, no arrays. I know how I could do it with parameters and arrays, lucky me. Any help is appreciated! Here is my incomplete code: public class Stairs { public static final int LENGTH=5; public static void main(String[] args) { printStairs(); } public static void printStairs() { for (int allStairs=1; allStairs<=15; allStairs++) { for (int spaces=1; spaces<=(-5*allStairs+30); spaces++) { System.out.print(" "); } for (int stair = 1; stair <= 5; stair++) { System.out.println(" o *******"); } } } }
Tags (comma-separated)
Save Edits
Cancel