Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. House Renovation variable number of doors, windows and bookcases Change the code from HW2 where the number of doors, windows and book cases is

a. House Renovation variable number of doors, windows and bookcases

Change the code from HW2 where the number of doors, windows and book cases is not known and part of the input. Thus you will ask for the DIMENSIONS of the room and the number of DOORS, WINDOWS AND BOOKCASES.

Only thing changing from HW2 is that you will be dynamically asking for the doors, windows and bookcases rest of the problem stays the same. The number of doors, windows and bookcases is different from HW2 but the costs and flooring options stay the same.

Then use the information to read in the DIMENSIONS and calculate the number of square feet of wall and flooring that will need to be worked. To test the program enter the same data below. The output will be the number square feet wall space and floor space Along with the cost of doing the walls and floors (floors are still fixed price per square foot used in HW1). Use the same data from HW2 on the selections for the flooring (see below)

First renovation project (THREE DOORS, ONE BOOKSHELF, NO WINDOWS)

o Room is 12 feet long, 12 feet wide, and 12 feet high

o Door 1 is 2 feet wide by 10 feet high

o Door 2 is 3 feet wide by 5 feet high

o Door 3 is 3 feet wide by 5 feet high

o Bookshelf is 8 feet long by 10 feet high by 2 feet deep

o No windows

Second renovation project (3 WINDOWS, 2 BOOKSHELFS, NO DOORS)

o Room is 24 feet long, 12 feet wide, and 8 feet high

o Window 1 is 2 feet wide by 6 feet high

o Window 2 is 3 feet wide by 5 feet high

o Window 3 is 8 feet wide by 5 feet high

o Bookshelf 1 is 8 feet long by 6 feet high by 3 feet deep

o Bookshelf 2 is 3 feet long by 6 feet high by 2 feet deep

o No doors

Third renovation project (ONE DOOR, 2 WINDOWSS, ONE BOOKSHELF)

o Room is 12.75 feet long, 11.25 feet wide, and 12 feet high

o Door is 1.95 feet wide by 10 feet high

o Window 1 is 2.5 feet wide by 5 feet high

o Window 2 is 6.8 feet wide by 7.2 feet high

o Bookshelf is 8 feet long by 6 feet high by 3 feet deep

Repeating the information from HW2:

For all three renovation projects from Project 1 use Tile= $4.00 /sq ft; Wood = $3.00/ sq ft; Carpet = $2.00/ sq ft and linoleum = $1.00/sq ft).

Use the following as the budget and preference:

Budget/preference

Renovation 1

Renovation 2

Renovation 3

User preference

0

1

3

Budget

255.00

250.00

400.00

hw2

import static java.lang.System.*;

import java.util.Scanner;

// Renovation Project

public class RenovationProjecthw2 {

{

}

public static void main(String args[]) {

double rheight, rwidth, rlength; //room height,width and length variabe

double dheight, dwidth; //door height and width variable

double w1height, w1width;//window1 height and width variable

double w2height, w2width;//window2 height and width variable

double bheight, bwidth, blength;//bookshelf height ,length and width variable

double paintArea, carpentArea, floorArea;

double paintCost, carpentCost = 0, floorCost, budget;

int preferences = 0;

String flooring = "";

Scanner s = new Scanner(System.in);

out.print("Enter the Room height : ");

rheight = s.nextDouble();

out.print(" Enter the Room width : ");

rwidth = s.nextDouble();

out.print(" Enter the Room length : ");

rlength = s.nextDouble();

out.print(" Enter the Door height : ");

dheight = s.nextDouble();

out.print(" Enter the Door width : ");

dwidth = s.nextDouble();

out.print(" Enter the Window1 height : ");

w1height = s.nextDouble();

out.print(" Enter the Window1 width : ");

w1width = s.nextDouble();

out.print(" Enter the Window2 height : ");

w2height = s.nextDouble();

out.print(" Enter the Window2 width : ");

w2width = s.nextDouble();

out.print(" Enter the bookshelf height : ");

bheight = s.nextDouble();

out.print(" Enter the bookshelf width : ");

bwidth = s.nextDouble();

out.print(" Enter the bookshelf length : ");

blength = s.nextDouble();

out.print(" Enter the painting cost per square feet: $");

paintCost = s.nextDouble();

// out.print(" Enter the carpenting cost per square feet: $");

// carpentCost = s.nextDouble();

out.print(" Choose Flooring type : 0: No Preferences 1: Ceramic Tile 2: Hardwood 3: Carpet 4: linoleum tile Enter Flooring type : ");

preferences = s.nextInt();

out.print(" Enter your budget for flooring: ");

budget = s.nextDouble();

paintArea = 2 * rheight * (rwidth + rlength) - (bheight * blength) - (w1width * w1height) - (w2width * w2height) - (dheight * dwidth); //calculation of paint area

carpentArea = (rwidth * rlength) - (bwidth * blength); //calculation of carpent area

switch (preferences) {

case 0:

if (4 * carpentArea <= budget) {

carpentCost = 4;

flooring = "Ceramic Tile";

} else if (3 * carpentArea <= budget) {

carpentCost = 3;

flooring = "Hardwood";

} else if (2 * carpentArea <= budget) {

carpentCost = 2;

flooring = "Carpet";

} else if (1 * carpentArea <= budget) {

carpentCost = 1;

flooring = "Lenolieum Tile";

} else {

carpentCost = 0;

flooring = "";

}

break;

case 1:

if (4 * carpentArea <= budget) {

carpentCost = 4;

flooring = "Ceramic Tile";

} else {

carpentCost = 0;

}

break;

case 2:

if (3 * carpentArea <= budget) {

carpentCost = 3;

flooring = "Hardwood";

} else {

carpentCost = 0;

}

break;

case 3:

if (2 * carpentArea <= budget) {

carpentCost = 2;

flooring = "Carpet";

} else {

carpentCost = 0;

}

break;

case 4:

if (1 * carpentArea <= budget) {

carpentCost = 1;

flooring = "Lenolieum Tile";

} else {

carpentCost = 0;

}

break;

}

out.println("Area of wall after removing the paining area : " + paintArea);

out.println("Area of floor after removing area of bookshelf : " + carpentArea);

out.println("Cost for painting : $" + (paintArea * paintCost));

if (carpentCost != 0) {

out.println("flooring type : " + flooring);

out.println("Cost for flooring : $" + (carpentArea * carpentCost));

} else {

out.println("No Affordable flooring available in given budget");

}

}

}

/*output

Enter the Room height : 12

Enter the Room width : 12

Enter the Room length : 12

Enter the Door height : 10

Enter the Door width : 2

Enter the Window1 height : 5

Enter the Window1 width : 3

Enter the Window2 height : 5

Enter the Window2 width : 3

Enter the bookshelf height : 10

Enter the bookshelf width : 2

Enter the bookshelf length : 8

Enter the painting cost per square feet: $1

Choose Flooring type :

0: No Preferences

1: Ceramic Tile

2: Hardwood

3: Carpet

4: linoleum tile

Enter Flooring type : 0

Enter your budget for flooring: 255

Area of wall after removing the paining area : 446.0

Area of floor after removing area of bookshelf : 128.0

Cost for painting : $446.0

flooring type : Lenolieum Tile

Cost for flooring : $128.0

renovation 2

Enter the Room height : 8

Enter the Room width : 12

Enter the Room length : 24

Enter the Door height : 6

Enter the Door width : 2

Enter the Window1 height : 5

Enter the Window1 width : 3

Enter the Window2 height : 5

Enter the Window2 width : 8

Enter the bookshelf height : 6

Enter the bookshelf width : 3

Enter the bookshelf length : 8

Enter the painting cost per square feet: $1.57

Choose Flooring type :

0: No Preferences

1: Ceramic Tile

2: Hardwood

3: Carpet

4: linoleum tile

Enter Flooring type : 1

Enter your budget for flooring: 250

Area of wall after removing the paining area : 461.0

Area of floor after removing area of bookshelf : 264.0

Cost for painting : $723.77

No Affordable flooring available in given budget

renovation 3

Enter the Room height : 12

Enter the Room width : 11.25

Enter the Room length : 12.75

Enter the Door height : 10

Enter the Door width : 1.95

Enter the Window1 height : 5

Enter the Window1 width : 2.5

Enter the Window2 height : 7.2

Enter the Window2 width : 6.8

Enter the bookshelf height : 6

Enter the bookshelf width : 3

Enter the bookshelf length : 8

Enter the painting cost per square feet: $0.95

Choose Flooring type :

0: No Preferences

1: Ceramic Tile

2: Hardwood

3: Carpet

4: linoleum tile

Enter Flooring type : 3

Enter your budget for flooring: 400

Area of wall after removing the paining area : 447.04

Area of floor after removing area of bookshelf : 119.4375

Cost for painting : $424.688

flooring type : Carpet

Cost for flooring : $238.875

*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Implementing Ai And Machine Learning For Business Optimization

Authors: Robert K Wiley

1st Edition

B0CPQJW72N, 979-8870675855

More Books

Students also viewed these Databases questions