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

I\'m stuck on this computer science program can someone help me please, thanks i

ID: 3667376 • Letter: I

Question

I'm stuck on this computer science program can someone help me please, thanks in advance



arguments, and display them in an appropriate message on the screen. 4. Paint Job Estimator 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

Explanation / Answer

import java.util.Scanner;
import java.text.DecimalFormat;

/**
* @author Srinivas Palli
*
*/
public class PaintJobEstimator {

   /**
   * @param args
   */
   public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
       try {

           int numberOfRooms;
           double pricePerGallon;

           System.out.print("Enter the number of rooms: ");
           numberOfRooms = input.nextInt();

           System.out.print("Enter the price of paint per gallon: ");
           pricePerGallon = input.nextDouble();

           int roomCount = 1;
           double totalWallSpace = 0;

           while (roomCount <= numberOfRooms) {
               System.out.println("Room No: " + roomCount);
               System.out.print("Enter wall Space: ");
               double wallSpaceForRoom = input.nextInt();
               roomCount += 1;
               totalWallSpace += wallSpaceForRoom;
           }

           double paintGallonsRequired = gallonsOfPaint(totalWallSpace);
           double laborHoursRequired = hoursOfLaborRequired(totalWallSpace);
           double laborCost = laborCharges(laborHoursRequired);
           double paintCost = costOfPaint(paintGallonsRequired, pricePerGallon);
           totalCostOfPaintJob(laborCost, paintCost, totalWallSpace);

       } catch (Exception e) {
           // TODO: handle exception
       }
   }

   /**
   * @param wallSpace
   * @return
   */
   public static double gallonsOfPaint(double wallSpace) {
       double paintGallons = wallSpace / 115;
       return paintGallons;
   }

   /**
   * @param wallSpace
   * @return
   */
   public static double hoursOfLaborRequired(double wallSpace) {
       double laborHours = (wallSpace / 115) * 8;
       return laborHours;
   }

   /**
   * @param gallons
   * @param price
   * @return
   */
   public static double costOfPaint(double gallons, double price) {
       double paintCost = gallons * price;
       return paintCost;
   }

   /**
   * @param hours
   * @return
   */
   public static double laborCharges(double hours) {
       double totalLaborCharges = hours * 18;
       return totalLaborCharges;
   }

   /**
   * @param laborCost
   * @param paintCost
   * @param totalWallSpace
   */
   public static void totalCostOfPaintJob(double laborCost, double paintCost,
           double totalWallSpace) {
       DecimalFormat twoDecimal = new DecimalFormat("#,##0.00");
       double totalCost = laborCost + paintCost;
       System.out.println("Total Wall Space: " + totalWallSpace);
       System.out.println("Labor cost: $" + twoDecimal.format(laborCost));
       System.out.println("Paint cost: $" + twoDecimal.format(paintCost));
       System.out.println("The totalcost of the paint job is: $"
               + twoDecimal.format(totalCost));
   }

}

OUTPUT:

Enter the number of rooms: 2
Enter the price of paint per gallon: 1054
Room No: 1
Enter wall Space: 580
Room No: 2
Enter wall Space: 460
Total Wall Space: 1040.0
Labor cost: $1,302.26
Paint cost: $9,531.83
The totalcost of the paint job is: $10,834.09