Ejemplo n.º 1
0
 public static function Calculate($json)
 {
     $counts = array();
     $community_arrayx = array();
     //non-functional water points
     $community_array = array();
     //water points per community
     $ranking_array = array();
     //ranking  by percentage
     $counter = 0;
     foreach ($json as $data => $value) {
         if (isset($value['water_functioning'])) {
             $stat = $value['water_functioning'];
             $community = $value['communities_villages'];
             if (!in_array($community_arrayx, $community)) {
                 array_push($community, $community_arrayx);
             }
             if (strcasecmp($stat, "yes") == 0) {
                 ++$counter;
             }
         }
     }
     $cc_arr = array();
     for ($y = 0; $y < count($community_arrayx); ++$y) {
         $comm = $community_arrayx[$y];
         $community_array[$comm] = calc::getWaterPointsToTal($json, $comm);
         $cc_arr[$comm] = calc::getBrokenWaterPointsToTal($json, $comm);
         $ranking_array = $cc_arr;
     }
     $counts['functional_water_points'] = $counter;
     $counts['number_of_water_points'] = json_encode($community_array);
     $counts['community_ranking'] = calc::getRanking($ranking_array);
     return $counts;
 }
Ejemplo n.º 2
0
} else {
    die('Config object ' . $useconf . ' not found!');
}
// Read url options
if (array_key_exists('calc_type', $_GET)) {
    $calc_type = $_GET['calc_type'];
    if ($calc_type == 'files') {
        $scm_getpaths = true;
    }
}
// get scm management class
require_once 'lib/scm_' . $scm_type . '.php';
// Calculator
require_once 'lib/calc_' . $calc_type . '.php';
// Visualizer
require_once 'lib/visual_' . $visual_type . '.php';
// login
$scm = new scm();
$scm::Login();
// get data
$log = $scm::GetLog();
// calculate
$calc = new calc();
$data = $calc->Calculate($log);
// Get header text
if ($visual_header == '') {
    $visual_header = $calc->GetHeader();
}
// visualize
$visual = new visual();
$visual->CreatePng($data);
Ejemplo n.º 3
0
<?php

require 'calcSalary.php';
$salary = $_GET["salary"];
$inss = calc::calcInss($salary);
$salary -= $inss;
$irpf = calc::calcIrpf($salary);
$salary -= $irpf;
$result = array('salary' => $salary, 'inss' => $inss, 'irpf' => $irpf);
echo json_encode($result);
Ejemplo n.º 4
0
    class calc
    {
        public $name;
        public $sub1;
        public $sub2;
        public $sub3;
        public function calc($a, $b, $c, $d)
        {
            $this->name = $a;
            $this->sub1 = $b;
            $this->sub2 = $c;
            $this->sub3 = $d;
        }
        public function getValue()
        {
            echo $this->name . "'s score:<br/><br/>";
            echo "Subject 1 score: " . $this->sub1 . "<br/>";
            echo "Subject 2 score: " . $this->sub2 . "<br/>";
            echo "Subject 3 score: " . $this->sub3 . "<br/><br/>";
            $sum = $this->sub1 + $this->sub2 + $this->sub3;
            echo "The total is " . $sum . "<br/>";
            $perc = $sum / 300 * 100;
            echo "The percentage score is " . $perc . "%<br/>";
            echo "<br/>";
        }
    }
    $obj = new calc($_REQUEST['name'], $_REQUEST['sub1'], $_REQUEST['sub2'], $_REQUEST['sub3']);
    $obj->getValue();
} else {
    echo "Form not submitted. Access Denied";
}
 function auto_convert($integer, $format, $toFormat)
 {
     $this->_set_params($integer, $format, $toFormat);
     $iterate = $this->get_key($this->format) - $this->get_key($this->toFormat);
     if ($iterate < 0) {
         $iterate = $iterate * -1;
     }
     //turn to positive
     $operator = $this->get_operator();
     return calc::compute($this->integer, $operator, $iterate);
 }
Ejemplo n.º 6
0
    function divide($number1, $number2)
    {
        $result = $number1 / $number2;
        echo "{$number1} divided by {$number2} is {$result}<br><br>";
        echo "{$number1} ▒ {$number2} = {$result}";
        exit;
    }
    function multiply($number1, $number2)
    {
        $result = $number1 * $number2;
        echo "The product of {$number1} and {$number2} is {$result}<br><br>";
        echo "{$number1} x {$number2} = {$result}";
        exit;
    }
}
$calc = new calc();
?>
<TITLE>PHP Calculator v2</TITLE>
<form name="calc" action="?page=calc" method="POST">
Number 1: <input type=text name=value1><br>
Number 2: <input type=text name=value2><br>
Operation: <input type=radio name=oper value="add">Addition <input type=radio name=oper value="subtract">Subtraction <input type=radio name=oper value="divide">Division <input type=radio name=oper value="multiply">Multiplication</input><br>
<input type=submit value="Calculate">
</form>
<?php 
if ($page == "calc") {
    $number1 = $_POST['value1'];
    $number2 = $_POST['value2'];
    $oper = $_POST['oper'];
    if (!$number1) {
        echo "You must enter number 1!";
Ejemplo n.º 7
0
 function __construct($a, $b, $c)
 {
     parent::__construct($a, $b);
     $this->c = $c;
 }