
x = $x;
$this->y = $y;
$hasil = $this->x + $this->y;
return $hasil;
}
public function Kali($x, $y)
{
$this->x = $x;
$this->y = $y;
$hasil = $this->x * $this->y;
return $hasil;
}
public function Kurang($x, $y)
{
$this->x = $x;
$this->y = $y;
$hasil = $this->x - $this->y;
return $hasil;
}
public function Bagi($x, $y)
{
$this->x = $x;
$this->y = $y;
$hasil = $this->x / $this->y;
return $hasil;
}
public function TampilkanForm()
{
echo '';
}
}
$data = new Matematika();
$data->TampilkanForm();
if ($_POST) {
$x = $_POST['x'];
$y = $_POST['y'];
if ($_POST['operasi'] == "tambah") {
echo "Hasil ".$x." + ".$y." = ".$data->Tambah($x, $y).""; } elseif ($_POST['operasi'] == "kali") { echo "Hasil ".$x." x ".$y." = ".$data->Kali($x, $y)."
"; } elseif ($_POST['operasi'] == "kurang") { echo "Hasil ".$x." - ".$y." = ".$data->Kurang($x, $y)."
"; } elseif ($_POST['operasi'] == "bagi") { echo "Hasil ".$x." / ".$y." = ".$data->Bagi($x, $y)."
"; } } ?> Hasilnya sebagai berikiut.

Bagi yang ingin mengikuti training Scriptcase bisa mengunjungi website www.OwenSolution.com
ReplyDelete