Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone help with my computer science class. In Java, Declare three variables of type double to represent height, width and depth of the house.
Can someone help with my computer science class. In Java, Declare three variables of type double to represent height, width and depth of the house. Let's
also initialize all these variables such that our house is feet tall, frontback walls are
feet wide, and the side walls are feet deep. Remember that doubles represent numbers
with a decimal point, while integers represent whole numbers.
Print these values to the screen using the println method. Format your text and make sure to
label each value you print. ie don't print just the values give a label to each value in your
printout
Declare and initialize three more variables. All windows have the same size, so we will need a
value for height, width, and the number of windows on our house. height width
number of windows Pay attention to the data type for these values. Pick an appropriate
data type and descriptive names for your variables
Declare and initialize three more variables. All doors have the same size, so we will need a
value for height, width, and the number of doors on our house. height width
number of doors Pay attention to the data type for these values
Neatly print out the number of doors windows, and the size of each.
Declare six variables of type double. One each for the surface area of the roof,floor, side wall
left, side wall right, front wall and back wall. Initialize each variable to we will assign values
to these variables later as we complete calculations.
Declare two variables of type double for total surface area of the house. The st will be the
total surface area of our house ignoring windows and doors, the nd variable will store the
surface area with windows and doors areas subtracted from the total surface area.
Declare and initialize a String variable for each of the following strings stringsgood
badboringexcitingbigsmall and finally a string with your name. first name only is
ok
For the next several calculations, ignore the number of windows doors.
Create assignment statements to calculate and store the surface area of each wall of the house,
the roof, and the floor. Print these values out, and make sure to label them in your print
statements. dont just print out the numbers should be six walls, but only different values
You should use the variables you created in step above to store your results.
Create an assignment statement that stores the total surface area of your house to the variable
declared earlier step that will hold total surface area. add values together from previous
step
Print a statement that tells whose house this is uses an adjective to describe the house, and
prints the total surface area calculated in the previous step. To print your name and an adjective
for the house you should use string concatenation and of the String variables created in step
For example, I might print: This is David's House. It is boring. I would follow this up with
the surface area.
Now lets take into account the windows while calculating the surface area. Note that we can
use the surface area calculated in step subtract the total surface area of the windows #
windows X windowHeight X windowLength and assign this value to our nd variable for
storing total surface area.
Print the value calculated from step as well as a label to indicate this is the total surface area
minus windows.
Like in step find the total surface area window area door area Print the value
calculated in step as well as a label to indicate this is the total surface area minus windows
and doors. Also, using of the String variables created in step and string concatenation, print
a message saying whose house this is and an adjective to describe it I might print This house
belongs to David, and it is very big.
Note that at this point in your code, all the variables still have the values you previously
assigned to them.
Create a Rectangle object located at with width height Be sure to browse to
the java API to verify how the Rectangle constructor works
Print the x location of the Rectangle by using the getX method from the Rectangle class. The
code for this step will look like this:
System.out.printlnRectangle x location: myRectangle.getX;
Where the word myRectangle will be replaced with the variable name you chose in step
Print the y location of the Rectangle.
Print the width of the Rectangle.
Print the height of the Rectangle.
Use the grow method on your Rectangle object to increase the width by and the height by
Make sure to use the Java API and read the description of the grow method.
Repeat steps hint copy paste the code you wrote in those steps This will print the
current location and dimensions of the Rectangle.
Use the translate method to place the Re
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