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 DayApr 26, 2021

Answer To: i had upload file please follow the instruction make sure run on xampp

Sanghamitra answered on Apr 28 2021
147 Votes
TASK/task1/Calculator.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() {
    
return $this->getNumber1() + $this->getNumber2();
}
public function calcDifference() {
    
return $this->getNumber1() - $this->getNumber2();
}
public function calcProduct() {
    
return $this->getNumber1() * $this->getNumber2();
}
}
?>
TASK/task2/Calculator.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() {
    
return $this->getNumber1() + $this->getNumber2();
}
public function calcDifference() {
    
return $this->getNumber1() - $this->getNumber2();
}
public function calcProduct() {
    
return $this->getNumber1() * $this->getNumber2();
}
}
?>
TASK/task2/sumdiffprod.html
SUM/DIFF/PROD PROBLEM
Number1 :
Number2 :
TASK/task2/sumdiffprod.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

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here