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; //old code
- //I replaced JOptionPane With scanner, it should be fairly easy to understand if you have some problems dont hesitate to ask --verd
- import java.util.Scanner;
- 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)
- {
- Scanner s = new Scanner(System.in);//make object of scanner
- System.out.println("Enter size of each room (in squared feet): ");
- double RoomSize= s.nextDouble();
- //double RoomSize = getDouble("Enter size of each room (in squared feet): "); //old code
- System.out.println("Enter price of paint per gallon: ");
- double PaintCost = s.nextDouble();
- //double PaintCost = getDouble("Enter price of paint per gallon: "); //old code
- System.out.println("Enter number of rooms to paint: ");
- double RoomCount = s.nextDouble();
- //double RoomCount = getDouble("Enter number of rooms to paint: "); //old code
- s.close();
- 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); //old code
- System.out.println(Message);
- }
- // private static double getDouble (String Prompt) //old code
- // {
- //
- // String UserInput = JOptionPane.showInputDialog(Prompt);
- // return ((double)Double.parseDouble(UserInput));
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment