Question

Java: Paint Job Estimator

A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges$18.00 per hour for labor. Write a program that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. It should also ask for the square feet of wall space in each room. The program should have methods that return 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
Then it should display the data on the screen.

I fixed, and I got the following, but I think the all calculations have to be in each method... am I correct?
I compiled, and I got 4 errors. The errors said "cannot find symbol" where I was calling methods. Could you tell me where I should fix and how?
Thank you very much.

import java.util.Scanner;
import java.text.DecimalFormat;

public class PaintJobEstimator
{
public static void main(String[] args)
{
int sizeOfWall = 115;// Size of wall in
// each room is 115 ft^2.
int gallon = 1;// 1gallon to paint
// per 115 ft^2.
int hoursOfLabor = 8;// 8 hours to paint per
// 115 ft^2.
int laborCostPerHour = 18;// Labour cost per hour
// in each room

// Create Scanner object for kb input.
Scanner kb = new Scanner(System.in);

// Create a DecimalFormat object.
DecimalFormat formatter = new DecimalFormat("#0.00");

//------------------
// Questions to ask
//------------------
// Get the # of ft^2 of wall space in each room.
System.out.print("Enter the number of wall space in " +
"each room (in square feet): ");
double sizeToPaint = kb.nextDouble();

// Get the # of rooms to be painted.
System.out.print("Enter the number of rooms " +
"to be painted: ");
double numberOfRooms = kb.nextDouble();

// Get the price of the paint per gallon.
System.out.print("Enter the price of the paint " +
"per gallon: ");
double priceOfPaint = kb.nextDouble();

// Calculate how many of 115 ft^2 block is there.
double roomCostUnit
= (sizeToPaint * numberOfRooms)/sizeOfWall;

//--------------------------
// Call methods and display
//--------------------------
// Call cal1 method
double ans1 = cal1(gallon, roomCostUnit);
// Display
System.out.print("The number of gallons of "
+ "paint required: " + ans1);

// Call cal2 method
double ans2 = cal2(hoursOfLabor, roomCostUnit);
// Display
System.out.print("The hours of labor " +
"required: " + ans2);

// Call cal3 method
double ans3 = cal3(numberOfGallons, priceOfPaint);
//Display
System.out.print("The cost of the paint: "
+ ans3);

// Call cal4 method
double ans4 = cal4(hoursRequired, laborCostPerHour);
// Display
System.out.print("The labor charges: "
+ ans4);

// Call cal5 method
double ans5 = cal5(paintCostTotal, laborCostTotal);
// Display
System.out.print("The total cost of the " +
&õ;&x.øi5p;"paint job: " + ans5);

//---------------------------------------------------------------
// Calculation:
//1. The number of gallons of paint required
double numberOfGallons = gallon * roomCostUnit;
//2. Calculate the hours of labor required.
double hoursRequired = hoursOfLabor * roomCostUnit;
//3. Calculate the cost of the paint.
double paintCostTotal = numberOfGallons * priceOfPaint;
//4. The labor charges.
double laborCostTotal = hoursRequired * laborCostPerHour;
//5. The total cost of the paint job.
double jobCostTotal = paintCostTotal + laborCostTotal;
//----------------------------------------------------------------
}

// cal1 method
public static double cal1(double Gallon, double Room_Cost_Unit)
{
double result;

result = Gallon * Room_Cost_Unit;
return result;
}

// cal2 method
public static double cal2(double Hours_Of_Labor, double Room_Cost_Unit)
{
double result;

result = Hours_Of_Labor * Room_Cost_Unit;
return result;
}

// cal3 method
public static double cal3(double Number_Of_Gallons, double Price_Of_Paint)
{
double result;

result = Number_Of_Gallons * Price_Of_Paint;
return result;
}

// cal4 method
public static double cal4(double Hours_Required, double Labor_Cost_Per_Hour)
{
double result;

result = Hours_Required * Labor_Cost_Per_Hour;
return result;
}

// cal5 method
public static double cal5(double Paint_Cost_Total, double Labor_Cost_Total)
{
double result;
&7Í;bx.øi5sp;result = Paint_Cost_Total + Labor_Cost_Total;
return result;

0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

Program Plan:

• Create a class PaintJobEstimator.

• Create a method NoOfGallons() to calculate the number of gallons of paint required.

• Create a method hoursOfLabour() to calculate the number of hours of labour required.

• Create a method costOfPaint() to calculate the total cost of paint.

• Create a method laborCharges() to calculate the labor charges.

• Create a method totalCost() to calculate the total cost of paint job.

• Define the main method.

o Prompt the user to enter number of rooms.

o Prompt the user to enter wall space of room.

o Prompt the user to enter the price of the paint per gallon.

o Call method NoOfGallons() to calculate the number of gallons of paint.

o Call method hoursOfLabour() to calculate the number of hours of labour.

required.

o Call method costOfPaint() to calculate the total cost of paint.

o Call method laborCharges() to calculate the labor charges.

o Call method totalCost() to calculate the total cost of paint job.

o Display the number Of gallons of paint required, hours of labour required, cost of the paint, labor charges, and total cost of paint job.

Program:

//import the required classes

import javax.swing.JOptionPane;

import java.text.DecimalFormat;

//start of PaintJobEstimator

public class PaintJobEstimator

{

// start of main

public static void main(String[] args)

{

// Declare the required variables

int rooms;

double sum = 0, wallspace, gallonPrice,

gallonsRequired, laborHour, paintCost,

charges, total;

DecimalFormat formatter =

new DecimalFormat("#0.00");

String input = "";

// Prompt the user to enter number of rooms

input = JOptionPane

.showInputDialog("Enter number of rooms: ");

// read number of rooms into variable rooms

rooms = Integer.parseInt(input);

// validate rooms

while (rooms < 1)

{

input = JOptionPane.showInputDialog(

"Enter number of rooms: ");

rooms = Integer.parseInt(input);

}

// loop to enter the wall space of each room

for (int x = 1; x <= rooms; x++)

{

// Prompt the user to enter wall space of

// room

input = JOptionPane.showInputDialog(

"Enter wall space of room" + x

+ " (in square feet): ");

wallspace = Double.parseDouble(input);

// calculate the total wall space of all

//rooms

sum = sum + wallspace;

} // end for

// Prompt the user to enter the price of the

// paint per gallon

input = JOptionPane.showInputDialog("Enter

the price of the paint per gallon:");

// read price of the paint per gallon into

// variable gallonprice

gallonPrice = Double.parseDouble(input);

// call method NoOfGallons() to get the number of

// gallons of paint required

gallonsRequired = NoOfGallons(sum);

//Display the number of gallons of paint required

System.out.println( "The number Of gallons of

paint required: "+ Math.round(gallonsRequired));

// call method hoursOfLabour() to get the number

// of hours of labour required

laborHour = hoursOfLabour(gallonsRequired);

//Display the number of hours of labour required

System.out.println("The hours of labour required:

+formatter.format(laborHour));

// call method costOfPaint() to get the total

// cost of paint

paintCost = costOfPaint(gallonsRequired,

gallonPrice);

//Display the total cost of paint

System.out.println("The cost of the paint is: $"

+formatter.format(paintCost));

// call method laborCharges() to get the labor

// charges

charges = laborCharges(laborHour);

//Display the labor charges

System.out.println("The labor charges: $"

+formatter.format(charges));

// call method totalCost() to get the total cost

// of paint job

total = totalCost(paintCost, charges);

//Display the total cost of paint job

System.out.println( "The total cost of paint job:

$" +formatter.format(total));

// pause system for a while

System.exit(0);

}// end main

//method to calculate the number of gallons of paint

// required

static double NoOfGallons(double sum)

{

return (sum / 115);

}

//method to calculate the number of gallons of paint // required

static double hoursOfLabour(double gallonsRequired)

{

return gallonsRequired * 8;

}

//method to calculate the cost of paint

static double costOfPaint(double gallonsRequired,

double gallonPrice)

{

return gallonsRequired * gallonPrice;

}

//method to calculate the labor charges

static double laborCharges(double laborHour)

{

return laborHour * 18;

}

//method to calculate the total cost of paint job

static double totalCost(double paintCost,

double charges)

{

return paintCost + charges;

}

}

Output:

The number Of gallons of paint required: 7

The hours of labour required: 53.57

The cost of the paint is: $167.39

The labor charges: $964.17

The total cost of paint job: $1131.57

Add a comment
Answer #2

Java code

--------------------------------------------------------------------------------------------------------------------------------------

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package paintcost;

import java.util.Scanner;


public class PaintCost {
//variable declaration
int room;
double paintCostperGallon;
int squareFeet[];
int totalSquarefeet;
double totalGallon;
double laborHourfind;
double paintCost,labourCost,totalCost;

//inpt from user
void input()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter number of rooms: ");
room=sc.nextInt();
System.out.print("Enter paint cost per gallon: ");
paintCostperGallon=sc.nextDouble();

squareFeet=new int[room];
for(int i=0;i {
System.out.print("Enter square feet of "+i +" room: ");
squareFeet[i]=sc.nextInt();
totalSquarefeet+=squareFeet[i];
}
  
  
}
//gallon fins
void gallonFind()
{
totalGallon=totalSquarefeet/115.0;
totalGallon=Math.round( totalGallon*100.0)/100.0;
  
}
//hours of labour find
void hoursLabor()
{
laborHourfind=8*totalSquarefeet/115.0;
laborHourfind=Math.round( laborHourfind*100.0)/100.0;

}
//cost of paint find
void costPaint()
{
paintCost=paintCostperGallon*totalGallon;
paintCost=Math.round(paintCost*100.0)/100.0;
}
//cost of laboour find
void costLabour()
{
labourCost=laborHourfind*18.00;
  
}
//toatal cost find
void totalCostfind()
{
totalCost=paintCost+labourCost;
  
}
//display
void display()
{
System.out.println("Total Gallon required is: "+totalGallon);
System.out.println("Total Labour hours required is: "+laborHourfind);
System.out.println("Paint cost is: $"+paintCost);
System.out.println("Labour cost is: $"+labourCost);
System.out.println("Total cost is: $"+totalCost);
}
  
public static void main(String[] args) {
//object creation
PaintCost ob=new PaintCost();
//input from user
ob.input();
  
ob.gallonFind();
ob.hoursLabor();
ob.costPaint();
ob.costLabour();
ob.totalCostfind();
//display data on console
ob.display();
}
  
}

----------------------------------------------------------------------------------------------------------------------------------

Output

Add a comment
Know the answer?
Add Answer to:
Java: Paint Job Estimator
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT