grodek118

Paint Job Estimator

Feb 5th, 2023
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     private static final int WALL_SPACE_SQFT = 115;
  6.     private static final int GALLONS_OF_PAINT = 1;
  7.     private static final int HOURS_OF_LABOR = 8;
  8.     private static final double CHARGES_PER_HOUR = 18.00;
  9.  
  10.     public static void main(String[] args)
  11.     {
  12.         Scanner scanner = new Scanner(System.in);
  13.         System.out.println("Enter number of rooms");
  14.         int rooms = scanner.nextInt();
  15.  
  16.         double [] roomWallSpaces = new double[rooms];
  17.  
  18.         System.out.println("Enter wall space SQF per room");
  19.         for (int i = 0; i < roomWallSpaces.length; i++)
  20.         {
  21.             roomWallSpaces[i] = scanner.nextDouble();
  22.         }
  23.  
  24.         System.out.println("Enter price per gallon of paint");
  25.         double pricePerGallon = scanner.nextDouble();
  26.  
  27.         System.out.println("Number of gallons of paint required: " + getGallonsRequired(roomWallSpaces));
  28.         System.out.println("Number of hours of labor required: " + getHoursOfLaborRequired(roomWallSpaces));
  29.         System.out.println("The cost of paint required: " + getTotalCostOfPaint(roomWallSpaces, pricePerGallon));
  30.         System.out.println("Total labor charges: " + getTotalLaborCharges(roomWallSpaces));
  31.         System.out.println("Total cost of the paint job: " + getTotalCostOfPaint(roomWallSpaces, pricePerGallon));
  32.     }
  33.  
  34.     public static double getOverallRoomWallSpaces(double[] roomWallSpaces)
  35.     {
  36.         double overallRoomWallSpaces = 0;
  37.  
  38.         for (double roomWallSpace : roomWallSpaces) {
  39.             overallRoomWallSpaces += roomWallSpace;
  40.         }
  41.  
  42.         return overallRoomWallSpaces;
  43.     }
  44.  
  45.     public static double getGallonsRequired(double[] roomWallSpaces)
  46.     {
  47.         return  getOverallRoomWallSpaces(roomWallSpaces) / WALL_SPACE_SQFT * GALLONS_OF_PAINT;
  48.     }
  49.  
  50.     public static double getHoursOfLaborRequired(double[] roomWallSpaces)
  51.     {
  52.         return getOverallRoomWallSpaces(roomWallSpaces) / WALL_SPACE_SQFT * HOURS_OF_LABOR;
  53.     }
  54.  
  55.     public static double getTotalCostOfPaint(double[] roomWallSpaces, double pricePerGallon)
  56.     {
  57.         return getGallonsRequired(roomWallSpaces) * pricePerGallon;
  58.     }
  59.  
  60.     public static double getTotalLaborCharges(double[] roomWallSpaces)
  61.     {
  62.         return getHoursOfLaborRequired(roomWallSpaces) * HOURS_OF_LABOR;
  63.     }
  64.  
  65.     public static double getTotalCharges(double[] roomWallSpaces, double pricePerGallon)
  66.     {
  67.         return getTotalCostOfPaint(roomWallSpaces, pricePerGallon) + getTotalLaborCharges(roomWallSpaces);
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment