Write a program that computes the cost of painting and installing carpet in a
room. Assume that the room has one door, two windows, and one bookshelf. Your program must do the following:
a. Prompts the user to enter, in feet, the length, width, and height of a
room. Read the dimensions of the room.
b. Prompts the user to enter the widths and heights, in feet, of the door,
each window, and the bookshelf. Read these quantities.
c. Prompts the user to enter the cost, per square foot, of painting the
walls. Read these quantities.
d. Prompts the user to enter of cost, per square foot, of installing carpet.
Read these quantities.
import java.util.Scanner;
public class CarpentPaintCounter {
public static void main(String[] args) {
double roomLength = 0;
double roomWidth = 0;
double roomHeight = 0;
double doorWidth = 0;
double doorHeight = 0;
double windowOneWidth = 0;
double windowOneHeight = 0;
double windowTwoWidth = 0;
double windowTwoHeight = 0;
double bookshelfHeight = 0;
double bookshelfWidth = 0;
double paintingCosts = 0;
double carpenteringCosts = 0;
Scanner scan = new Scanner(System.in);
System.out.println("Please insert room length and press Enter: ");
roomLength = scan.nextDouble();
System.out.println("Please insert room width and press Enter: ");
roomWidth = scan.nextDouble();
System.out.println("Please insert room height and press Enter: ");
roomHeight = scan.nextDouble();
System.out.println(
"Room length is: " + roomLength + ", width: " + roomWidth + " and height: " + roomHeight + " feet");
System.out.println("\nPlease provide door width and press Enter: ");
doorWidth = scan.nextDouble();
System.out.println("Please provide door height and press Enter: ");
doorHeight = scan.nextDouble();
System.out.println("Please provide first window width and press Enter: ");
windowOneWidth = scan.nextDouble();
System.out.println("Please provide first window height and press Enter: ");
windowOneHeight = scan.nextDouble();
System.out.println("Please provide second window width and press Enter: ");
windowTwoWidth = scan.nextDouble();
System.out.println("Please provide second window height and press Enter: ");
windowTwoHeight = scan.nextDouble();
System.out.println("Please provide book shelf height and press Enter: ");
bookshelfHeight = scan.nextDouble();
System.out.println("Please provide book shelf width and press Enter: ");
bookshelfWidth = scan.nextDouble();
System.out.println("Please provide painting costs for one sqare feet and press Enter: ");
paintingCosts = scan.nextDouble();
System.out.println("Please provide carpentering costs for one sqare feet and press Enter: ");
carpenteringCosts = scan.nextDouble();
double costForWallPainting = Math.ceil(((2 * (roomLength * roomHeight) + 2 * (roomHeight * roomWidth))
- (doorWidth * doorHeight) - (windowOneWidth * windowOneHeight) - (windowTwoWidth * windowTwoHeight)
- (bookshelfHeight * bookshelfWidth)) * paintingCosts);
System.out.println("Cost of wall painting:" + costForWallPainting);
double costforFloorCarpentering = Math.ceil(roomLength * roomWidth * carpenteringCosts);
System.out.println("Cost of floor carpentering: " + costforFloorCarpentering);
scan.close();
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF