Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

Cost Per Square Foot Area Function

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) .".";

?>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions