Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Number.of People: Individual Dus: By the beginning of next week\'s lab session G

ID: 3749896 • Letter: N

Question

Number.of People: Individual Dus: By the beginning of next week's lab session Gradet: Please refer to the COMP 1900 syllabus for your lab T Coding Style Use camelCase for variabl A. Questions about e names, use consistent indentation in your code, and include a reasonable hroughout your code. The TAs may dedact points for poor coding styls a Within the 1900 folder on your desktop, create a new folder named Lab2HW for a home remodeling company, and your boss wants a program to (8 pts) Suppose you're working help with cost estimates for painting a rectangular room containing one door and one 1. window. Within u LabzHW folder, create a new program named Paint.java Your program should allow your the user to enter the following information (you can assume that the user will enter sensible input)y . Length, width, and height of the room (in t) Width and height of the room's dooe (in ft) Width and height of the room's window (in fi) The type of paint to use (standard or deluxe) Your program should then compute the total cost of paint required, based on the following guidelines . One can of paint costs $14.99 (standard) or $29.99 (deluxe) . One can of paint is enough to cover 250 ft of wall area * Paint must be bought by the can. For example, if you find that your room's wall area is 358 the precise amount of paint you need would be 358/250 -1.432 cans. Alas, Home Depot and Lowe's generally do not sell fractional cans. Hence, you would need to buy 2 cans to get this amount Include only the room's walls (not the floor, ceiling, door, or window) in your paint calculations Add the 9.25% TN sales tax to get your final cost. Finally, your program should display the following information to the user . The paintable wall area of the room, in t? (excluding the floor, ceiling, door, and window) .The number of cans of paint required . The before-tax cost of the paint . The dollar amount of tax . The final, after-tax cost of the paint Hints: Make sure that you are calculating the wall area correctly. It is NOT length width height- that gives you the yolume of the room! You may want to sketch a diagram to heip you visualize the room

Explanation / Answer

ScreenShot

Program

//Packages for formatting and keyboard read
import java.text.DecimalFormat;
import java.util.Scanner;

public class Paint {
   //constant value variables
    public static double standardPaintCost=14.99;
    public static double deluxePaintCost=29.99;
    public static double>     private static DecimalFormat df2 = new DecimalFormat(".##");
   public static void main(String[] args) {
       //Scanner object for read
       Scanner sc=new Scanner(System.in);
       //Variables for read and calculations
       double room_length,room_width,room_height,door_width,door_height,window_width,window_height,cost = 0,finalCost=0,tax=0,area;
       int numCan=0;
       char type;
       //User prompts to enter room details
       System.out.print("Enter length of the room(in ft):");
       room_length=sc.nextDouble();
       System.out.print("Enter width of the room(in ft):");
       room_width=sc.nextDouble();
       System.out.print("Enter height of the room(in ft):");
       room_height=sc.nextDouble();
       System.out.print("Enter width of the door(in ft):");
       door_width=sc.nextDouble();
       System.out.print("Enter height of the door(in ft):");
       door_height=sc.nextDouble();
       System.out.print("Enter width of the window(in ft):");
       window_width=sc.nextDouble();
       System.out.print("Enter height of the window(in ft):");
       window_height=sc.nextDouble();
       System.out.print("Enter type of paint(s for standard,d for deluxe):");
       type = sc.next().charAt(0);
       //Calculate wall area
       area=(2*(room_width*room_height)+2*(room_length*room_height))-(door_width*door_height)-(window_width*window_height);
       //Find number of cans
       numCan=(int)Math.ceil(area/oneCan);
       //Calculate the cost according to type of paint
       if(type=='s'||type=='S') {
           cost=numCan*standardPaintCost;
       }
       else if(type=='d'||type=='D') {
           cost=numCan*deluxePaintCost;
       }
       //Calculate tax
       tax=cost*(9.25/100);
       //Calculate final cost
       finalCost=cost+tax;
       //Display result
       System.out.println("The paintable wall area    ="+area+"ft^2");
       System.out.println("The number of cans Required="+numCan);
       System.out.println("The before-tax cost        =$"+df2.format(cost));
       System.out.println("The amount of tax          =$"+df2.format(tax));
       System.out.println("The final,after-tax cost   =$"+df2.format(finalCost));

   }

}

Output

Enter length of the room(in ft):10
Enter width of the room(in ft):5
Enter height of the room(in ft):15
Enter width of the door(in ft):3
Enter height of the door(in ft):7
Enter width of the window(in ft):2
Enter height of the window(in ft):5
Enter type of paint(s for standard,d for deluxe):s
The paintable wall area    =419.0ft^2
The number of cans Required=2
The before-tax cost        =$29.98
The amount of tax          =$2.77
The final,after-tax cost   =$32.75