Question
This PHP exercise required that you declare two functions rArea() and totalCost(). You are required to create two functions. The rArea() function will accept two
This PHP exercise required that you declare two functions rArea() and totalCost().
You are required to create two functions. The rArea() function will accept two arguments and the totalCost() function will accept three arguments. Each function will perform a calculation using the arguments and then return an integer value. That returned value will then be used a sentence that is displayed using an echo() statement.
The first function will calculate the area of a property based on the height and width of the property. Using these two arguments being width and height (Reminder: area = width * height.) echo out a sentence stating A room of length " .$length . "ft and width " . $width . "ft has an area of " . rArea($length ,$width ), where area is the function return value.
The second part will require that you calculate the total cost of the property if the square foot of the property is defined by the variable $ftCost. The calculation of the property total per square foot is total area multiplied by the cost per square foot defined by the variable $ftCost. Then echo this sentence The total cost of a room oflength ." $length . "ft and width " . $width . "ft area at $" . $ftCost . "per square foot is " . totalCost($length ,$width,$cost) . where the total cost is the function returned value.
Total Property Cost Calculator
$length = 20;
$width = 4;
$ftCost = 75;
//define rArea() function //ADD rArea() FUNCTION HERE
//call function rArea() echo "A room of length " . $length . "ft and width " . $width . "ft has an area of " . rArea($length ,$width ) .".";
//define totalCost() function
//ADD totalCost() FUNCTION HERE
//call function totalCost() echo "The total cost of a room of length ." $length . "ft and width " . $width . "ft area at $" . $ftCost . "per square foot is " . totalCost($length ,$width,$cost) .".";
?>