Advertisement
thracia776

paintJob

Aug 26th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. // A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor.
  2.  
  3. import javax.swing.JOptionPane;
  4. public class PaintJob {
  5.  
  6.  
  7. private static int SizeToCost = 115;
  8. private static int PaintToCost = 1;
  9. private static int LabourToCost = 8;
  10. private static int LabourCostPerHour = 18;
  11.  
  12.  
  13. public static void main(String[] args)
  14. {
  15.  
  16. double RoomSize = getDouble("Enter size of each room (in squared feet): ");
  17.  
  18.  
  19. double PaintCost = getDouble("Enter price of paint per gallon: ");
  20.  
  21.  
  22. double RoomCount = getDouble("Enter number of rooms to paint: ");
  23.  
  24. double RoomCostUnit = (RoomSize * RoomCount) / SizeToCost;
  25.  
  26.  
  27. double PaintCountTotal = PaintToCost * RoomCostUnit;
  28.  
  29. double LabourCountTotal = LabourToCost * RoomCostUnit;
  30.  
  31.  
  32. double PaintCostTotal = PaintCountTotal * PaintCost;
  33.  
  34.  
  35. double LabourCostTotal = LabourCountTotal * LabourCostPerHour;
  36.  
  37.  
  38. double JobCostTotal = PaintCostTotal + LabourCostTotal;
  39.  
  40.  
  41. double DisplayPaintCountTotal = (double)((int)(PaintCountTotal * 100) / 100.0);
  42. double DisplayLabourCountTotal = (double)((int)(LabourCountTotal * 100) / 100.0);
  43. double DisplayPaintCostTotal = (double)((int)(PaintCostTotal * 100) / 100.0);
  44. double DisplayLabourCostTotal = (double)((int)(LabourCostTotal * 100) / 100.0);
  45. double DisplayJobCostTotal = (double)((int)(JobCostTotal * 100) / 100.0);
  46.  
  47. String Message = "The number of gallons of paint required = " + DisplayPaintCountTotal + "\n" +
  48. "The hours of labor required = " + DisplayLabourCountTotal + "\n" +
  49. "The cost of the paint = " + DisplayPaintCostTotal + "\n" +
  50. "The labor charges = " + DisplayLabourCostTotal + "\n" +
  51. "The total cost of the paint job = " + DisplayJobCostTotal + "\n";
  52. JOptionPane.showMessageDialog(null, Message);
  53. }
  54.  
  55. private static double getDouble (String Prompt)
  56. {
  57.  
  58. String UserInput = JOptionPane.showInputDialog(Prompt);
  59. return ((double)Double.parseDouble(UserInput));
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement