Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

**Please help. Submit in Java Part 1 - Area of a Wall Given Height and Width In Part 1 you will write code to prompt

**Please help. Submit in Java

Part 1 - Area of a Wall Given Height and Width In Part 1 you will write code to prompt the user to enter the height and the width of a wall (in feet). Then your code will compute and output the area of that wall. For this part, you will need to declare some variables to store the height and width of the wall, as well as the area of the wall. These three variables should be int variables. After you have declared and initialized your variables, write a Java statement to prompt the user to input a wall's height. Then write a statement to collect the user's input and store it in your height variable. Now, write a Java statement to prompt the user to input a wall's width. Then write a statement to collect the user's input and store it in your width variable. Next, write Java statement to compute the area of a wall with the given height and width, and store this value n your area variable. Finally, write a line of code to output the area of the wall.

Hint: You can use printf with a %d format specifier to format the output of the Wall area, like this: System.out.printf("Wall area : %d square feet ", area); Or you can use String concatenation to accomplish the same thing, like this: System.out.println("Wall area : " + area + " square feet");

Here is an example of what the user should see when the program runs.

Enter wall height (feet) : 12

Enter wall width (feet) : 15

Wall area : 180 square feet

Make sure that, with the input values 12 and 15, your program output looks exactly like the example above

Part 2 - Gallons of Paint Needed Extend your program to also calculate and output the amount of paint (in gallons) needed to paint the wall. You will need to declare a double variable to store the number of gallons of paint needed. One gallon of paint will cover 350 square feet. Write a Java statement to compute the number of gallons of paint needed to cover a wall with the given dimensions, and store this value in your gallons variable. Then, output the amount of paint needed, with two decimal places of precision. You should use a System.out.printf statement and the %.2f conversion specifier to accomplish this.

Here is an example of what the user should see when the program runs.

Enter wall height (feet) : 12

Enter wall width (feet) : 15

Wall area : 180 square feet

Paint needed : 0.51 gallons

Make sure that, with the input values 12 and 15, your program output looks exactly like the example above

Part 3 - Cans of Paint needed Extend your program to also calculate and output the number of one-gallon cans needed to paint the wall. Hints: Use a Math.ceil method to round up to the nearest full gallon. You can use printf with a %d format specifier to format the output of the Cans needed, or you can use String concatenation to accomplish the same thing.

Here is an example of what the user should see when the program runs.

Enter wall height (feet) : 12

Enter wall width (feet) : 15

Wall area : 180 square feet

Paint needed : 0.51 gallons

Cans needed : 1 can(s)

Make sure that, with the input values 12 and 15, your program output looks exactly like the example above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions