Module 3 Program Assignment: House Painting
Directions
This exercise requires
designing a program which solves the problem described in the problem
statement below. Provide comments as necessary in your pseudo-code and
the Java program.
Your solution must include these
components:
- Flowchart
- Pseudo-code
- Hierarchy Chart
- Program Coded
- Program Output
Problem Statement
A painting company has
determined that to paint 115 square feet of wall space, the task will
require one gallon of paint and 8 hours of labor. The company charges
$20.00 per hour for labor. Design a modular program that
asks the user to enter the number of square feet of wall space to be
painted and the price of paint per gallon. The program should then
calculate and display the following data:
- The number of gallons of paint required
- The hours of labor required
- The cost of the paint
- The labor charges
- The total cost of the paint job
Your program should contain the
following modules:
- Module main.
Accepts user input of the wall space (in square feet) and the price
of a gallon of paint. Calculates the gallons of paint needed to
paint the room, the cost of the paint, the number of labor hours
needed, and the cost of labor. Calls summaryPaint, passing
all necessary variables.
- Module summaryPaint.
Accepts the gallons of paint needed, the cost of the paint, the
number of labor hours needed, and the cost of labor. Calculates
and displays total cost of the job and statistics shown in the
Expected Output.
Expected Output
Enter wall space in square
feet: 500
Enter price of paint per
gallon: 25.99
Gallons of paint: 4.3478260869565215
Hours of labor: 34.78260869565217
Paint charges: $112.99999999999999
Labor charges: $695.6521739130435
Total Cost: $808.6521739130435
Submission
You must submit your solution
as a Microsoft Word document (.docx) with all components included in the
one document. Also, submit the Java source code file (.java).
Solution
Answer
1)
Flowchart that represent the program will take the input and calculation
the result
2)
Pseudo-code that display the steps for the program and how operate it and
display the result
Declare Real wallSpace
Display "Enter wall space in
square feet: "
Input wallSpace
Declare Real priceofpaint
Display "Enter price of paint per
gallon:"
Input priceofpaint
Declare Real gallonsofpaint
Set gallonsofpaint = wallSpace * (1.0 /
115.0)
Display "Gallons of paint: ",
gallonsofpaint
Declare Real hoursoflabor
Set hoursoflabor = 8.0 / 115 *
wallSpace
Declare Real paintcharges
Set paintcharges = gallonsofpaint *
priceofpaint
Display "Paint charges: ",
paintcharges
Declare Real laborcharges
Set laborcharges = 8.0 / 115 *
wallSpace * 20
Display "Labor charges: ",
laborcharges
Declare Real totalCost
Set totalCost = paintcharges +
laborcharges
Display "Total Cost: ",
totalCost
3)
Hierarchy Chart display the processes in program
4)
Program Coded in java that will takes inputs for wall space and price of paint
per gallon the calculate the required results
import java.util.Scanner;
public class HousePainting {
// main to driver the program
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double Wall_Space = 0;
double price_of_paint ;
double One_hour_price = 20.0;
double Cost_for_labor = 8.0/115;
double gallon_needed = 1.0/115.0 ;
double Gallons_of_paint =0;
System.out.print ("Enter wall
space in square feet: ");
Wall_Space= input.nextDouble();
System.out.print ("Enter price of
paint per gallon: ");
price_of_paint= input.nextDouble();
Gallons_of_paint = Wall_Space *
gallon_needed ;
System.out.println ("Gallons of
paint: "+Gallons_of_paint);
double Hours_of_labor = Cost_for_labor
* Wall_Space;
System.out.println ("Hours of
labor: "+Hours_of_labor);
double Paint_charges = Gallons_of_paint
* price_of_paint;
System.out.println("Paint charges:
"+Paint_charges);
double Labor_charges =
Cost_for_labor * Wall_Space*
One_hour_price ;
System.out.println ("Labor
charges: "+Labor_charges);
double Total_Cost = summaryPaint(
Gallons_of_paint, price_of_paint ,Hours_of_labor , One_hour_price );
System.out.println
("Total Cost: "+Total_Cost);
} // end of main
public
static double summaryPaint(double Gallons_of_paint,double Paint_charges,double Hours_of_labor,double
One_hour_price ){
return Gallons_of_paint*Paint_charges +
Hours_of_labor*One_hour_price ;
}// end of summaryPaint
}//
end of class
5) Program Output after run the
program
Enter
wall space in square feet: 500
Enter
price of paint per gallon: 25.99
Gallons
of paint: 4.3478260869565215
Hours
of labor: 34.78260869565217
Paint
charges: 112.99999999999999
Labor
charges: 695.6521739130435
Total
Cost: 808.6521739130435