VerdommeMan

Step1 Help

Aug 27th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.65 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; //old code
  4. //I replaced JOptionPane With scanner, it should be fairly easy to understand if you have some problems dont hesitate to ask --verd
  5. import java.util.Scanner;
  6. public class PaintJob {
  7.  
  8.    
  9.         private static int SizeToCost = 115;
  10.         private static int PaintToCost = 1;
  11.         private static int LabourToCost = 8;     
  12.         private static int LabourCostPerHour = 18; 
  13.  
  14.  
  15.         public static void main(String[] args)
  16.         {
  17.         Scanner s = new Scanner(System.in);//make object of scanner
  18.        
  19.         System.out.println("Enter size of each room (in squared feet): ");
  20.         double RoomSize= s.nextDouble();   
  21.         //double RoomSize = getDouble("Enter size of each room (in squared feet): "); //old code
  22.  
  23.         System.out.println("Enter price of paint per gallon: ");
  24.         double PaintCost = s.nextDouble();
  25.         //double PaintCost = getDouble("Enter price of paint per gallon: "); //old code
  26.  
  27.         System.out.println("Enter number of rooms to paint: ");
  28.         double RoomCount = s.nextDouble();
  29.         //double RoomCount = getDouble("Enter number of rooms to paint: "); //old code
  30.         s.close();
  31.         double RoomCostUnit = (RoomSize * RoomCount) / SizeToCost;
  32.  
  33.  
  34.         double PaintCountTotal = PaintToCost * RoomCostUnit;
  35.  
  36.         double LabourCountTotal = LabourToCost * RoomCostUnit;
  37.  
  38.  
  39.         double PaintCostTotal = PaintCountTotal * PaintCost;
  40.  
  41.    
  42.         double LabourCostTotal = LabourCountTotal * LabourCostPerHour;
  43.  
  44.        
  45.         double JobCostTotal = PaintCostTotal + LabourCostTotal;
  46.  
  47.  
  48.         double DisplayPaintCountTotal = (double)((int)(PaintCountTotal * 100) / 100.0);
  49.         double DisplayLabourCountTotal = (double)((int)(LabourCountTotal * 100) / 100.0);
  50.         double DisplayPaintCostTotal = (double)((int)(PaintCostTotal * 100) / 100.0);
  51.         double DisplayLabourCostTotal = (double)((int)(LabourCostTotal * 100) / 100.0);
  52.         double DisplayJobCostTotal = (double)((int)(JobCostTotal * 100) / 100.0);
  53.  
  54.         String Message = "The number of gallons of paint required = " + DisplayPaintCountTotal + "\n" +
  55.         "The hours of labor required = " + DisplayLabourCountTotal + "\n" +
  56.         "The cost of the paint = " + DisplayPaintCostTotal + "\n" +
  57.         "The labor charges = " + DisplayLabourCostTotal + "\n" +
  58.         "The total cost of the paint job = " + DisplayJobCostTotal + "\n";
  59.         //JOptionPane.showMessageDialog(null, Message); //old code
  60.         System.out.println(Message);
  61.         }
  62.  
  63. //      private static double getDouble (String Prompt)  //old code
  64. //      {
  65. //
  66. //      String UserInput = JOptionPane.showInputDialog(Prompt);
  67. //      return ((double)Double.parseDouble(UserInput));
  68. //      }
  69.         }
Advertisement
Add Comment
Please, Sign In to add comment