NO print or println in any of your methods except the main method. A painting co
ID: 3671623 • Letter: N
Question
NO print or println in any of your methods except the main method.
A painting company has determined that for every 112 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 calculates the amount of paint, hours of labor, the cost of paint, labor charges, and the total cost for a given room. The square feet of wall space of the room will be given to you. Your program must output the amount of paint, hours of labor, and the cost of paint, labor charges, and the total cost.
You must declare class constants for the values 112, 8 and 18. You must use meaningful names.
You need to declare variables such as size, paintPrice,…
You need to run your program with the data provided as the sample output.
Your program must have the following methods besides the main method:
1.A method that receives the square feet as its parameter and returns the gallons of paint needed.
2.A method that receives the square feet as its parameter and returns the hours of labor required.
3.A method that receives the number of gallons of paint and cost of a gallon as its parameters and returns the cost of paint.
4.A methods that receives hours of labor needed as its parameter and returns the labor charges.
5.A method that receives the labor cost and the paint cost as its parameters and returns the total cost.
You must output the following
Room Size: 112
The cost of paint per gallon: 23.8
Gallons of paint: 1
Hours of labor: 8
Cost of paint: 24
Cost of labor: 144
Total cost: 168
Room Size: 2000
The cost of paint per gallon: 23.8
Gallons of paint: 18
Hours of labor: 143
Cost of paint: 425
Cost of labor: 2571
Total cost: 2996
Room Size: 4100
The cost of paint per gallon: 23.8
Gallons of paint: 37
Hours of labor: 293
Cost of paint: 871
Cost of labor: 5271
Total cost: 6143
Explanation / Answer
import java.util.Scanner;
import java.text.DecimalFormat;
public class PaintJobEstimator
{
public static void main(String[] args)
{
int sizeOfWall = 115;
int gallon = 1;
int hoursOfLabor = 8;
int laborCostPerHour = 18;
Scanner kb = new Scanner(System.in);
DecimalFormat formatter = new DecimalFormat("#0.00");
System.out.print("Enter the number of wall space in " +"each room (in square feet): ");
double sizeToPaint = kb.nextDouble();
System.out.print("Enter the number of rooms " +"to be painted: ");
double numberOfRooms = kb.nextDouble();
System.out.print("Enter the price of the paint " +"per gallon: ");
double priceOfPaint = kb.nextDouble();
double roomCostUnit= (sizeToPaint * numberOfRooms)/sizeOfWall;
double numberOfGallons = gallon * roomCostUnit;
double hoursRequired = hoursOfLabor * roomCostUnit;
double paintCostTotal = numberOfGallons * priceOfPaint;
double laborCostTotal = hoursRequired * laborCostPerHour;
double jobCostTotal = paintCostTotal + laborCostTotal;
double ans1 = cal1(gallon, roomCostUnit);
System.out.println("The number of gallons of "+ "paint required: " +formatter.format(ans1));
double ans2 = cal2(hoursOfLabor, roomCostUnit);
System.out.println("The hours of labor " +"required: " +formatter.format(ans2));
double ans3 = cal3(numberOfGallons, priceOfPaint);
System.out.println("The cost of the paint: "+ formatter.format(ans3));
double ans4 = cal4(hoursRequired, laborCostPerHour);
System.out.println("The labor charges: "+ formatter.format(ans4));
double ans5 = cal5(paintCostTotal, laborCostTotal);
System.out.println("The total cost of the " +"paint job: " +formatter.format(ans5));
}
public static double cal1(double Gallon, double Room_Cost_Unit)
{
double result;
result = Gallon * Room_Cost_Unit;
return result;
}
public static double cal2(double Hours_Of_Labor, double Room_Cost_Unit)
{
double result;
result = Hours_Of_Labor * Room_Cost_Unit;
return result;
}
public static double cal3(double Number_Of_Gallons, double Price_Of_Paint)
{
double result;
result = Number_Of_Gallons * Price_Of_Paint;
return result;
}
public static double cal4(double Hours_Required, double Labor_Cost_Per_Hour)
{
double result;
result = Hours_Required * Labor_Cost_Per_Hour;
return result;
}
public static double cal5(double Paint_Cost_Total, double Labor_Cost_Total)
{
double result;
result = Paint_Cost_Total + Labor_Cost_Total;
return result;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.