My program should use print
and println
statements to draw a building on my console window. The building will have a variable number of stories and windows on each story. The windows also will be of varied heights and widths. Everything works fine, but I am having trouble with the width of the windows. I would really appreciate any help!
Is this how to write in pseudo code?
Do how many stories high the building will be? (1-4)
While stories is less than MINSTORIESHIGH or stories is greater than MAXSTORIESHIGH
Do how many windows on each story? (1-4)
While windows is less than MINWINDOWS or windows is greater than MAXWINDOWS
Do how wide each window will be? (1-4)
While wide is less than MINWIDE or wide is greater than MAXWIDE
Do how tall each window will be? (1-4)
While tall is less than MINTALL or tall is greater than MAXTALL
Let s is 0 and s is less than stories increments s by 1 each iteration of the loop
Display top row of story and walls
Let a is 0 and a is less than windows increments a by 1 each iteration of the loop
Display windows borders, inner window borders, window borders, walls, and floor
OUTPUT
import java.util.Scanner;
public class BuildingAssign {
public static void main (String [] args){
int stories;
int windows;
int wide;
int tall;
final int MAXSTORIESHIGH= 4;
final int MINSTORIESHIGH = 1;
final int MAXWINDOWS = 4;
final int MINWINDOWS = 1;
final int MAXWIDE = 4;
final int MINWIDE = 1;
final int MAXTALL = 4;
final int MINTALL = 1;
Scanner in = new Scanner(System.in);
do {
System.out.print("How many stories high the building will be? (1-4): ");
stories = in.nextInt();
}while (stories < MINSTORIESHIGH || stories > MAXSTORIESHIGH);
do {
System.out.print("How many windows on each story? (1-4): ");
windows = in.nextInt();
}while (windows < MINWINDOWS || windows > MAXWINDOWS);
do {
System.out.print("How wide each window will be? (1-4): ");
wide = in.nextInt();
}while (wide < MINWIDE || wide > MAXWIDE);
do {
System.out.print("How tall each window will be? (1-4): ");
tall = in.nextInt();
}while (tall < MINTALL || tall > MAXTALL);
for (int s=0; s<stories; s++)
{
System.out.println ("***********"); // printTopRowOfStory
System.out.println ("* *"); // printWalls
for (int a=0; a<windows; a++)
{
System.out.println ("* *** *** *"); // printWindowBorders
for (int t=0; t<tall; t++)
{
System.out.println("* * * * * *"); // printInnerWindowBorders
}
System.out.println("* *** *** *"); // printWindowBorders
System.out.println("* *"); // printWalls
}
System.out.println("***********"); // printFloor
}
}
}