A painting company has determined that for every 115 square feet of wall space,
ID: 3776189 • Letter: A
Question
Explanation / Answer
Please follow the code and comments for description :
CODE :
import java.text.DecimalFormat; // reuired imports
import java.util.Scanner;
public class PaintingCharges { // class to run the code
private static DecimalFormat df = new DecimalFormat(".##"); // class the formats the decimal values to two digits
public static void main(String[] args) { // driver method
double wallSpace, paintPrice, paintNeeded, paintCost, labrReq, labrChrgs, totalCst; // local variables
Scanner sc = new Scanner(System.in); // scanner class to get the dat
System.out.print("Please Enter the Wall space to be Painted (in square feet) : "); //prompt for the user
wallSpace = sc.nextDouble(); // get the data
System.out.print("Please Enter the Price of the Paint per Gallon : "); // prompt for the user
paintPrice = sc.nextDouble(); // get the data
paintNeeded = paintRequired(wallSpace); // call the method to calculate the paint needed
System.out.println(" The total Paint Required is : " + df.format(paintNeeded) + " gallon(s)."); // print the data to console
paintCost = costOfPaint(paintPrice, paintNeeded); // call the method to calculate the paint cost
System.out.println("The Cost For the Paint is : $ " + df.format(paintCost));// print the data to console
labrReq = laborHours(wallSpace); // call the method to calculate the labor hrs needed
System.out.println("The Hours of Labor Required are : " + df.format(labrReq) + " Hours."); // print the data to console
labrChrgs = laborCharges(labrReq); // call the method to calculate the labor charges
System.out.println("The Labor Charges are : $ " + df.format(labrChrgs)); // print the data to console
totalCst = totalCost(paintCost, labrChrgs); // call the method to calculate the total cost
System.out.println("The Total Cost for the Paint Job is : $ " + df.format(totalCst)); // print the data to console
}
public static double paintRequired(double wallSpace) { // method to calulate the paint required
double paintReq = wallSpace / 115;
return paintReq;
}
public static double costOfPaint(double paintPrice, double paintNeeded) { // method to calulate the paint cost
double paintCst = paintNeeded * paintPrice;
return paintCst;
}
public static double laborHours(double wallSpace) { // method to calulate the labor needed
double lbrHrs = (wallSpace / 115) * 8;
return lbrHrs;
}
public static double laborCharges(double labrReq) { // method to calulate the labor charges
double lbrChrgs = labrReq * 18;
return lbrChrgs;
}
public static double totalCost(double paintCost, double labrChrgs) { // method to calulate the total cost
double totCst = paintCost + labrChrgs;
return totCst;
}
}
OUTPUT :
Please Enter the Wall space to be Painted (in square feet) : 235
Please Enter the Price of the Paint per Gallon : 50
The total Paint Required is : 2.04 gallon(s).
The Cost For the Paint is : $ 102.17
The Hours of Labor Required are : 16.35 Hours.
The Labor Charges are : $ 294.26
The Total Cost for the Paint Job is : $ 396.43
Hope this is helpful.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.