Program 2 You are to write a program that will accept as input the total square
ID: 3646070 • Letter: P
Question
Program 2You are to write a program that will accept as input the total square footage of wall space of a room and the price of a gallon of paint. It will then return the number of gallons of paint required, the hours of labor required, the cost of the paint, the labor charges, and the total cost of the paint job.
You are to write 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
You are to use the following additional information to determine the above items:
? One gallon of paint covers 115 square feet.
? It takes 8 hours to paint 115 square feet.
? The labor rate is $18.00/hour.
The display will show:
Square Footage: Price per gallon of paint: Number of gallons required: Total hours required: Total cost of paint: Total labor charges: Total cost of Job:
PLEASE GIVE FULL STEP BY STEP PROGRAM IN JAVA LANGUAGE FOR 5 STAR RATING
Explanation / Answer
mport javax.swing.JOptionPane; public class PSlab5PaintingCompany { private static int SizeToCost = 115; // Cost calculated per 115 squared feet private static int PaintToCost = 1; // 1 gallon of paint used per 115 squared feet private static int LabourToCost = 8; // 8 hours to paint per 115 squared feet private static int LabourCostPerHour = 18; // Labour cot per hour public static void main(String[] args) { // -------------- // Get user input // -------------- //Get the user input of square feet. double RoomSize = getDouble("Enter size of each room (in squared feet): "); //Get the user's input on gallons of paint needed double PaintCost = getDouble("Enter price of paint per gallon: "); //Get the user's input on gallons of paint needed double RoomCount = getDouble("Enter number of rooms to paint: "); // ------------------------ // Now, do our calculations // ------------------------ // Calc. how many of 115 sq. feet blocks is there double RoomCostUnit = (RoomSize * RoomCount) / SizeToCost; // The number of gallons of paint required double PaintCountTotal = PaintToCost * RoomCostUnit; //2. The hours of labor required double LabourCountTotal = LabourToCost * RoomCostUnit; //3. The cost of the paint double PaintCostTotal = PaintCountTotal * PaintCost; //4. The labor charges double LabourCostTotal = LabourCountTotal * LabourCostPerHour; //5. The total cost of the paint job double JobCostTotal = PaintCostTotal + LabourCostTotal; // --------------- // Display results // --------------- double DisplayPaintCountTotal = (double)((int)(PaintCountTotal * 100) / 100.0); double DisplayLabourCountTotal = (double)((int)(LabourCountTotal * 100) / 100.0); double DisplayPaintCostTotal = (double)((int)(PaintCostTotal * 100) / 100.0); double DisplayLabourCostTotal = (double)((int)(LabourCostTotal * 100) / 100.0); double DisplayJobCostTotal = (double)((int)(JobCostTotal * 100) / 100.0); String Message = "The number of gallons of paint required = " + DisplayPaintCountTotal + " " + "The hours of labor required = " + DisplayLabourCountTotal + " " + "The cost of the paint = " + DisplayPaintCostTotal + " " + "The labor charges = " + DisplayLabourCostTotal + " " + "The total cost of the paint job = " + DisplayJobCostTotal + " "; JOptionPane.showMessageDialog(null, Message); } private static double getDouble (String Prompt) { //System.out.print(Prompt); //Scanner InFile = new Scanner(System.in); //String UserInput = InFile.nextLine(); String UserInput = JOptionPane.showInputDialog(Prompt); return ((double)Double.parseDouble(UserInput)); } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.