Great Deal! Get Instant \$10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

# i had upload file please follow the instruction make sure run on xampp

1 answer below Â»
i had upload file please follow the instruction make sure run on xampp
Answered Same Day Apr 26, 2021

## Solution

Sanghamitra answered on Apr 28 2021
TASK/task1/Calculator.php
?php
class Calculator {

private \$_fval, \$_sval;
public function __construct() {
\$this->_sval = '';\$this->_fval = '';

}
public function setNumber1(\$num){

\$this->_fval = \$num;

}
public function getNumber1(){

return \$this->_fval;
}
public function setNumber2(\$num){

\$this->_sval = \$num;

}
public function getNumber2(){

return \$this->_sval;
}
public function calcSum() {

eturn \$this->getNumber1() + \$this->getNumber2();
}
public function calcDifference() {

eturn \$this->getNumber1() - \$this->getNumber2();
}
public function calcProduct() {

eturn \$this->getNumber1() * \$this->getNumber2();
}
}
?
TASK/task2/Calculator.php
?php
class Calculator {

private \$_fval, \$_sval;
public function __construct() {
\$this->_sval = '';\$this->_fval = '';

}
public function setNumber1(\$num){

\$this->_fval = \$num;

}
public function getNumber1(){

return \$this->_fval;
}
public function setNumber2(\$num){

\$this->_sval = \$num;

}
public function getNumber2(){

return \$this->_sval;
}
public function calcSum() {

eturn \$this->getNumber1() + \$this->getNumber2();
}
public function calcDifference() {

eturn \$this->getNumber1() - \$this->getNumber2();
}
public function calcProduct() {

eturn \$this->getNumber1() * \$this->getNumber2();
}
}
?
TASK/task2/sumdiffprod.html
SUM/DIFF/PROD PROBLEM
Number1 :
Number2 :
TASK/task2/sumdiffprod.php
?php
include "model/Calculator.php";
function filter_inputdata(\$data) {
\$data = trim(\$data);
\$data = stripslashes(\$data);
\$data = htmlspecialchars(\$data);
return \$data;
}
\$number1 = filter_inputdata(\$_POST['number1']);
\$number2 = filter_inputdata(\$_POST['number2']);
if(isset(\$_POST['number1']) && isset(\$_POST['number1']) && \$number1 !='' && \$number2 !='' ){
validating Input params
if(\$number1 >0 && \$number2 >0 ){
validating if both input params are numeric or not

\$mycalc = new Calculator();
\$mycalc->setNumber1(\$number1);
\$mycalc->setNumber2(\$number2);
if(isset(\$_POST['sum'])){
echo "SUM = ".\$mycalc-> calcSum()."
";
}
if(isset(\$_POST['diff'])){
echo "DIFFERENCE = ".\$mycalc-> calcDifference()."
";
}
if(isset(\$_POST['prod'])){

echo "PROD = ".\$mycalc-> calcProduct()."
";
}
if(isset(\$_POST['all'])){
echo "SUM = ".\$mycalc-> calcSum()."
";
echo "DIFFERENCE = ".\$mycalc-> calcDifference()."
";
echo "PROD = ".\$mycalc-> calcProduct()."
";
}
}else{
echo "Both Number1 and Number2 should be...
SOLUTION.PDF

## Related Questions & Answers

More Questions Â»

### Submit New Assignment

Copy and Paste Your Assignment Here