Create a program named PaintingEstimate whose Main() method prompts a user for length and width of a room in feet. Create a method that accepts the values and then computes the cost of painting the room, assuming the room is rectangular and has four full walls and 9-foot ceilings. The price of the job is $6 per square foot. Return the price to the Main() method, and display it.

Respuesta :

ijeggs

Answer:

   public static double paintingCost(double roomLength, double roomWitdth){

       double roomDimension = roomLength*roomWitdth;

       double ceilingCost = 6*9; //Since the ceiling is 9-feets ($6/feet)

       double totalCost = (roomDimension*6)+ceilingCost;

       return  totalCost;

   }

Using Java programming language, A complete program is with a call to the method is given in the explanation section

Explanation:

import java.util.Scanner;

public class PaintingEstimate {

   public static void main(String[] args) {

       System.out.println("Please Enter the Length and Width of the Room in Feets");

       Scanner in = new Scanner(System.in);

       double roomLen = in.nextDouble();

       double roomWit = in.nextDouble();

//Calling the method in the output statement

       System.out.println("The total cost of painting the walls and ceiling is:  "+paintingCost(roomLen,roomWit)+" dollars");

}

   public static double paintingCost(double roomLength, double roomWitdth){

       double roomDimension = roomLength*roomWitdth;

       double ceilingCost = 6*9; //Since the ceiling is 9-feets ($6/feet)

       double totalCost = (roomDimension*6)+ceilingCost;

       return  totalCost;

   }

}