Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor.
- import javax.swing.JOptionPane;
- public class PaintJob {
- private static int SizeToCost = 115;
- private static int PaintToCost = 1;
- private static int LabourToCost = 8;
- private static int LabourCostPerHour = 18;
- public static void main(String[] args)
- {
- double RoomSize = getDouble("Enter size of each room (in squared feet): ");
- double PaintCost = getDouble("Enter price of paint per gallon: ");
- double RoomCount = getDouble("Enter number of rooms to paint: ");
- double RoomCostUnit = (RoomSize * RoomCount) / SizeToCost;
- double PaintCountTotal = PaintToCost * RoomCostUnit;
- double LabourCountTotal = LabourToCost * RoomCostUnit;
- double PaintCostTotal = PaintCountTotal * PaintCost;
- double LabourCostTotal = LabourCountTotal * LabourCostPerHour;
- double JobCostTotal = PaintCostTotal + LabourCostTotal;
- 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 + "\n" +
- "The hours of labor required = " + DisplayLabourCountTotal + "\n" +
- "The cost of the paint = " + DisplayPaintCostTotal + "\n" +
- "The labor charges = " + DisplayLabourCostTotal + "\n" +
- "The total cost of the paint job = " + DisplayJobCostTotal + "\n";
- JOptionPane.showMessageDialog(null, Message);
- }
- private static double getDouble (String Prompt)
- {
- String UserInput = JOptionPane.showInputDialog(Prompt);
- return ((double)Double.parseDouble(UserInput));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement