Enhance Php File Tests Interest Rate Entry Make Sure Also Less Equal 15 Use Operator Rate Q26260201
A) Enhance the phpfile so it tests the interest rate entry to make sure it is alsoless than or equal to 15. To do that, use an OR operator. If therate isn’t valid, display an error message reading “rate must begreater than zero and less than or equal to 15.”
B) Modify the php fileso it tests the years entry to make sure it is a valid numberthat’s greater than zero and less than or equal to 50. if it isn’t,display an error message like the first one.
C) modify the php fileso it uses embedded PHP to display the current date at the bottomof the web page like this: “this calculation was done on01/14/2018.”
PHP file:
$investment = $_POST[‘investment’];
$interest_rate = $_POST[‘interest_rate’];
$years = $_POST[‘years’];
if ( empty($investment) ) {
$error_message =’Investment is a required field.’; }
else if ( !is_numeric($investment) ) {
$error_message =’Investment must be a valid number.’; }
else if ( $investment <= 0 ) {
$error_message =’Investment must be greater than zero.’; }
else if ( empty($interest_rate) ) {
$error_message =’Interest rate is a required field.’; }
else if ( !is_numeric($interest_rate) ) {
$error_message =’Interest rate must be a valid number.’; }
else if ( $interest_rate <= 0 ) {
$error_message =’Interest rate must be greater than zero.’; }
else {
$error_message = ”;}
if ($error_message != ”) {
include(‘index.php’);
exit();
}
$future_value = $investment;
for ($i = 1; $i <= $years; $i++) {
$future_value =($future_value + ($future_value * $interest_rate *.01));
}
$investment_f = ‘$’.number_format($investment,2);
$yearly_rate_f = $interest_rate.’%’;
$future_value_f =’$’.number_format($future_value, 2);
?>
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
Future Value Calculator
Future Value Calculator
InvestmentAmount:
Yearly InterestRate:
Number ofYears:
Future Value:
index file:
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
Future Value Calculator
Future Value Calculator
Investment Amount:
value=”
“/>
Yearly Interest Rate:
value=””/>
Number of Years:
value=””/>