This program will compute the cost of painting the walls and installing carpet i
ID: 3745730 • Letter: T
Question
This program will compute the cost of painting the walls and installing carpet in a room. Assume that the room has one door, two windows and one bookshelf that take up room on the walls and decrease the area of walls that needs to be painted. The bookshelf will also decrease the floor of the room. amount of carpet that will cover the Complete the following tasks: 1. Create a new java console application in IntelliJ, and name it CostCalculator 2. You will need to declare global variables that will hold all of the size information for windows, door, bookshelf and the room. main method "All input AND output should be done using the JOptionPane library utilized in class 3. The main method will only contain a single line of code that will call the first of several other methods. All you need to do is write the call to method 2 in main. Method 2: 4. Prompt the user to enter the length, width and height of the room that is to be painted and record that data in the appropriate global variables declared in step 2. 5. Call method 3. Method 3: 6. Prompt the user to enter the widths and heights, in feet, of the door and each window and record that data in the appropriate global variables declared in step 2. 7. Call method 4. Method 4: 8. Prompt the user for the width, height and depth the bookshelf and record that data in the appropriate global variables declared in step 2 9. Call method 5 Method 5: 10. Prompt the user to enter the cost, per square foot, of painting the walls and record that data in the appropriate global variables declared in step 2. 11. Prompt the user to enter the cost, per square foot, of installing carpet and record that data in the appropriate global variables declared in step 2. 12. Call the last method. Method 6: 13. Output the cost of painting the walls, the cost of installing the carpet and the total cost of the renovation.Explanation / Answer
To understand a problem we have to identify the constraints available.
In a simple way, the problem/question here is to calculate the total cost of painting and cost of carpet needed in a room. The program/available methods define the program in an algorithm.
Let's define each step needed for the program.
First, we have to craete a java program named CostCalculater. Here the problem is we have to find the actual cost needed to paint the room by decreasing the bookshelf's area and also the carpet needed to fill the room .
To imply this, we need to declare the variables needed for each method, thst is the height,width,length of the room, the length and width of door and windows etc. As explained in the question, we have to use different methods for each item(room,door,window,carpet,bookshelf).
Let us see how the program is implemented.
Before that all the input and output should be done using JOptionPane library functions. It is a set of functions to display outputs and get inputs .
According to the question, each method must implement in a pipelining way, that is like a chain of methods.
The main method should contain a single line of code that calls another method. For example
Let method 2 is GetRoomData()
method 3 is GetDoorWindowData()
method 4 is GetBookshelfData()
method 5 is GetPaintingCost() and GetCarpetCost()
method 6 is TotalCost()
As explained each method contains different variables to store the appropriate data values like the length,height,cost etc.
From main method itself, each method contains another method to call, that means each method contains another method inside it. This must be done because each variable declared in the main method can only be used inside it.
After reading all the required data from user(from keyboard) all the appropriate data is assigned to the corresponding variables.
In method 6, we have to use all the variables to find the final cost.
That is, to find the cost to paint the wall, we decrease the area needed by the shelf to the whole room.
In this way by using basic maths, we can find all the other cost.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.