Question: import java.util.Scanner; import java.io.*; public class DemoRoom { public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println(Enter Room length, width and height :);
import java.util.Scanner; import java.io.*;
public class DemoRoom {
public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println("Enter Room length, width and height :"); double r_length = sc.nextDouble(); double r_width = sc.nextDouble(); double r_height = sc.nextDouble(); System.out.println("Enter Door width, height :"); double d_width = sc.nextDouble(); double d_height = sc.nextDouble(); System.out.println("Enter Window1 width, height :"); double w1_width = sc.nextDouble(); double w1_height = sc.nextDouble(); System.out.println("Enter Window2 width, height :"); double w2_width = sc.nextDouble(); double w2_height = sc.nextDouble(); System.out.println("Enter bookself width, height,depth :"); double b_width = sc.nextDouble(); double b_height = sc.nextDouble(); double b_depth = sc.nextDouble(); System.out.println("Enter cost per square foot painting :"); double ct_painting = sc.nextDouble(); System.out.println("Enter cost per square foot carpeting :"); double ct_carpeting = sc.nextDouble();
double r_area = 2 * r_length * r_height + 2 * r_height * r_width + r_length * r_width; double w1_area = w1_width * w1_height; double w2_area = w2_width * w2_height; double d_area = d_height * d_width; double b_area = b_height * b_width; double b_floor_area = b_depth * b_width; double r_floor_area = r_length * r_width;
double total_area_painting = r_area - (w1_area + w2_area + d_area + b_area); double total_area_carpeting = r_floor_area - b_floor_area; double total_cost_painting = total_area_painting * ct_painting; double total_cost_carpeting = total_area_carpeting * ct_carpeting; System.out.println(" Room is " + r_length + " feet long " + r_width + " feet wide and " + r_height + " feet high. "); System.out.println("Door is " + d_width + " feet high by " + d_height + " feet high. "); System.out.println("Window 1 is " + w1_width + " feet wide by " + w1_height + " feet high. "); System.out.println("Window 2 is " + w2_width + " feet wide by " + w2_height + " feet high. "); System.out.println("Bookshelf is " + b_width + " feet long by " + b_height + " feet high by " + b_depth + " feet deep "); System.out.println("Cost per square foot for painting is $" + ct_painting + " "); System.out.println("Cost per square foot for carpeting is $" + ct_carpeting + " "); System.out.println("Total area for painting is " + total_area_painting + " "); System.out.println("Total area for for carpeting is " + total_area_carpeting + " "); System.out.println("Total cost for painting is $" + total_cost_painting + " "); System.out.println("Total cost for for carpeting is $" + total_cost_carpeting + " "); try { FileWriter fw = new FileWriter("output.txt",true); fw.write(" Room is " + r_length + " feet long " + r_width + " feet wide and " + r_height + " feet high. "); fw.write("Door is " + d_width + " feet high by " + d_height + " feet high. "); fw.write("Window 1 is " + w1_width + " feet wide by " + w1_height + " feet high. "); fw.write("Window 2 is " + w2_width + " feet wide by " + w2_height + " feet high. "); fw.write("Bookshelf is " + b_width + " feet long by " + b_height + " feet high by " + b_depth + " feet deep "); fw.write("Cost per square foot for painting is $" + ct_painting + " "); fw.write("Cost per square foot for carpeting is $" + ct_carpeting + " "); fw.write("Total area for painting is " + total_area_painting + " "); fw.write("Total area for for carpeting is " + total_area_carpeting + " "); fw.write("Total cost for painting is $" + total_cost_painting + " "); fw.write("Total cost for for carpeting is $" + total_cost_carpeting + " "); fw.close(); } catch (Exception e) { e.printStackTrace(); }
} }
The program above calculates the floor space for carpets and wall space for paint. In this assignment you will add to that program.
using java. import java.util.Scanner;
Do not use objects.
Do not use;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
use good comments.
There is a budget assigned to the covering of the floor. There are four options for floor cover (Ceramic Tile = 1; Hardwood = 2, Carpet = 3; and linoleum tile = 4) each with a cost per square foot. In addition the customer has a preference for which covering they would like. The program will ask for input and read in the budget in dollars and cents, the cost per square foot for each of the different floor options and also ask for which one the customer prefers where 0 means the customer does not care and 1-4 if they have a specific preference for one of the four floor coverings
The program will then, based upon the square footage calculation, check if the users preference can be afforded (Hint use Switch statement), if not or the user selects 0 not caring, the program will start with the most expensive and check each flooring type until it finds the most expensive flooring that can be afforded. The program will output the type of flooring selected or a message that given the budget no flooring is affordable.
For all three renovation projects use the room and door, window and bookcase dimensions from Project 1 and 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 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
