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 functionwill perform a calculation using the arguments and then return an integervalue. 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 sentencestatingA room of length" .$length. "ftand width" .$width. "fthas 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 sentenceThe total cost of a roomoflength ." $length. "ftand 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 //ADDrArea()FUNCTION HERE
//call functionrArea() echo "A room of length " . $length. "ftand width " . $width. "fthas 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. "ftand width " . $width. "ft area at $" . $ftCost . "per square foot is " . totalCost($length,$width,$cost) .".";
?>