Anda di halaman 1dari 2

<html>

<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="kalkulator.php">
<div align="center">
<table width="67%" border="1">
<tr>
<td colspan="2"><div align="center"><strong>PROGRAMKALKULATOR
SEDERHANA</strong></div></td>
</tr>
<tr>
<td width="35%">NILAI PERTAMA</td>
<td width="65%"><input name="pertama" type="text" id="pertama"></td>
</tr>
<tr>
<td>OPERATOR</td>
<td><select name="operator" id="operator">
<option value="*">Perkalian</option>
<option value="+">Penjumlahan</option>
<option value="-">Pengurangan</option>
<option value="/">Pembagian</option>
</select></td>
</tr>
<tr>
<td height="26">NILAI KEDUA</td>
<td><input name="kedua" type="text" id="kedua"></td>
</tr>
<tr>
<td height="26" colspan="2"><input name="hitung" type="submit"
id="hitung" value="Hitung"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include ("kalukulator.html");
$pertama=$_POST['pertama'];
$kedua=$_POST['kedua'];
$operator=$_POST['operator'];
if($operator=='*'){
$hasil=$pertama*$kedua;
echo"<font size=4><center>Hasil Perkalian = <b>$hasil</b></center></font>";}
elseif($operator=='+'){
$hasil=$pertama+$kedua;
echo"<font size=4><center>Hasil Penjumlahan = <b>$hasil</b></center></font>";}
elseif($operator=='-'){
$hasil=$pertama-$kedua;
echo"<font size=4><center>Hasil Pengurangan = <b>$hasil</b></center></font>";}
elseif($operator=='/'){
$hasil=$pertama/$kedua;
echo"<font size=4><center>Hasil Penjumlahan = <b>$hasil</b></center></font>";}
?>
</body>
</html>

Anda mungkin juga menyukai