Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project 4 Paint Job Estimator DESCRIPTION: A painting company has determined tha

ID: 3621752 • Letter: P

Question

Project 4 Paint Job Estimator


DESCRIPTION: A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $ 18.00 per hour for labor. Write a program that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. It should also ask for the square feet of wall space in each room.
The program should have methods that return the following data: •
The number of gallons of paint required •
The hours of labor required •
The cost of the paint •
The labor charges •
The total cost of the paint job
Then it should display the data on the screen.

You will write several methods to complete the processing of the lab. A description of the required methods follows. Additional methods may also be used.

main method: This method will drive the PaintJobEstimator program. The body of this method will call the method getRooms to get the number of rooms to be painted, it will pass that number to the method getSquareFeet to get the total number of square feet to be painted. When the total number of square feet is acquired, the method getTotal will be called to get the total cost. Lastly, the estimated cost for the paint job will be displayed to the user.
getRooms method: The getRooms method prompts the user for the number of rooms to be painted and returns rte value entered by the user.

getSquareFeet method: The getSquareFeet method calculates the total square feet. It will receive the parameter rooms, loop for each room get the square feed and compute the total square feet. Finally, the total square feet is returned to the user.

getTotal method: The getTotal method calculates the total job estimate. It should receive the number of square feet to be painted as a parameter. It will need to get the price per gallon of paint to be used, and determine the total cost of the paint. It will also need to determine the total labor cost. Then adding the two together gives the total cost of the job. This is returned to the user.




Explanation / Answer

import java.util.Scanner;

public class PaintJobEstimator
{
      private static Scanner keyboard;
     
      public static void main(String[] args)
      {
            // open keyboard input
            keyboard = new Scanner(System.in);
           
            // find # of square feet
            double squareFeet = getSquareFeet(getRooms());
           
            System.out.printf("Total cost: %.2f ", getTotalCost(squareFeet));
      }
     
      public static double getTotalCost(double squareFeet)
      {
            // for efficiency, output of helper methods will be printed here
            double price = getPricePerGallon();
           
            double gallons = getNumGallonsOfPaint(squareFeet);
            System.out.printf("Gallons of paint required: %.2f ", gallons);
           
            double laborTime = getLaborTime(squareFeet);
            System.out.printf("Hours of labor required: %.2f ", laborTime);
           
            double paintCost = gallons * price;
            System.out.printf("Paint cost: %.2f ", paintCost);
           
            double laborCost = getLaborCost(laborTime);
            System.out.printf("Labor cost: %.2f ", laborCost);
           
            return laborCost + paintCost;
      }
     
      public static double getPricePerGallon()
      {
            System.out.print("Enter the price per gallon of paint: ");
            return keyboard.nextDouble();
      }
     
      public static int getRooms()
      {
            System.out.print("Enter the number of rooms: ");
            return keyboard.nextInt();
      }
     
      public static double getSquareFeet(int numRooms)
      {
            double output = 0.0;
           
            for(int i = 0; i < numRooms; i++)
            {
                  System.out.print("Enter the square feet for room "+(i+1)+": ");
                  output += keyboard.nextDouble();
            }
           
            return output;
      }
     
      public static double getNumGallonsOfPaint(double squareFeet)
      {
            return squareFeet/115.0;
      }
     
      public static double getLaborTime(double squareFeet)
      {
            return squareFeet/115*8;
      }
     
      public static double getLaborCost(double laborTime)
      {
            return laborTime*18.0;
      }
}