<head>
<title>Kalkulator</title>
</head>
<style>
body{
margin: 0;
background:url(bg1.jpg) top right no-repeat;
background-attachment: fixed;
}
td,th{
padding: 15px;
}
#kotak1{
height: 100%;
margin: 0;
}
#kotak2{
background:url(bg.jpg) top right no-repeat;
position: relative;
text-align: center;
padding:40px;
width: 80%;
margin:auto;
top:10%;
border-radius: 20px;
border: #000 double 4px;
}
</style>
<body>
<div id="kotak1">
<div id="kotak2">
<?php
echo "<table border=\"5\"><td align=center>
<form name='formlat' method='POST' action='".$_SERVER['PHP_SELF']."'>
Angka pertama<br><input name='angka1'/>
Angka ke dua<br><input name='angka2'/><br><input type='submit' value='Lihat'>
</td><td widht=\" 500px\">PILIH OPERATOR:<br>
<input type='radio' name='operator' value='+' />+
<input type='radio' name='operator' value='-' />-<br>
<input type='radio' name='operator' value='*' />*
<input type='radio' name='operator' value='/' />/<br>
<input type='radio' name='operator' value='%' />%</td></form>";
//operasi
echo "<td align=center width=\"500pxpx\">";
if(!isset($_POST['sumbit']))
{
if(empty($_POST['angka1'])&& empty($_POST['angka1'])&& empty($_POST['operator']))
{
echo"WELCOME TO SIMPLE KALKULATOR";
}
else if (!empty($_POST['angka1'])&& !empty($_POST['angka1'])&& !empty($_POST['operator']))
{
$operator=$_POST['operator'];
$a=$_POST['angka1'];
$b=$_POST['angka2'];
switch ($operator)
{
case('+');
{
$hasil=$a+$b;
break;
}
case('-');
{
$hasil=$a-$b;
break;
}
case('*');
{
$hasil=$a*$b;
break;
}
case('/');
{
$hasil=$a/$b;
break;
}
case('%');
{
$hasil=$a%$b;
break;
}
}
echo "Hasil = ".$a." ".$operator." ".$b." = ".$hasil;
}
}
echo "</font></td>";
?>
</div></div>
</body>
</html>
OUTPUT
0 comments:
Post a Comment