Script Program Gerbang Logika Matematika PHP
Halo selamat siang pengguna blog Agung Pramadipta.... bagaimana kabarnya masih jalan gak puasanya?..
kali ini saya mau bagi tips coding program Gerbang Logika Matematika....
Mungkin dari kalian bingung dikasih tugas sama dosen kalian buat program ini tapi kalian sendiri tidak bisa membuatnya :-) nih saya agung pramadipta mau kasih caranya....
1. jangan lupa program xampp kalian dalam kondisi ON ya gan
2. buat file index.php pada folder C://xamp/htdoc/gerbanglogika/index.php
3. lalu isi scriptnya sebagai berikut
<!DOCTYPE html>
<html>
<head>
<title>TUGAS MATEMATIKA 4 GERBANG LOGIKA</title>
</head>
<link href ="style.css" rel="stylesheet" type="text/css">
<body>
<center>
<p> TUGAS UAS MATEMATIKA 4 </p>
<p> GERBANG LOGIKA </p>
<form method="post" action="">
<table border="1">
<table border = '3' cellspacing = '2' cellpadding = '10'
style = 'border : #aaa; color: #101; font-family : arial; fot-size : 12px;'>
<tr>
<td class="head"> INPUT 1 </td>
<td class="satu" width = '5' align = 'center' > : </td>
<td class="satu"> <select name="input1">
<option value="0">false</option>
<option value="1">true</option>
</select> </td>
</tr>
<tr>
<td class="head"> INPUT 2 </td>
<td class="dua" align = 'center'> : </td>
<td class="dua"> <select name="input2">
<option value="0">false</option>
<option value="1">true</option>
</select>
</tr>
<tr>
<td colspan="3" align="center">
<button type="submit" name="and">AND</button>
<button type="submit" name="or">OR</button>
<button type="submit" name="not">NOT</button>
</td>
</tr>
</form>
</table>
<?php
if(isset($_POST['and'])){
$n1 = $_POST['input1'];
$n2 = $_POST['input2'];
if($n1 == 0 && $n2 == 0){
echo "<font color = 'red' size = '4'> <p> false AND false = 0 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 0) {
echo "<font color = 'red' size = '4'> <p> true AND false = 0 </p> </font> </b>";
}elseif ($n1 == 0 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> false AND true = 0 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> true AND true = 1 </p> </font> </b>";
}else{
echo "err";
}
}
if(isset($_POST['or'])){
$n1 = $_POST['input1'];
$n2 = $_POST['input2'];
if($n1 == 0 && $n2 == 0){
echo "<font color = 'red' size = '4'> <p> false OR false = 0 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 0) {
echo "<font color = 'red' size = '4'> <p> true OR false = 1 </p> </font> </b>";
}elseif ($n1 == 0 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> false OR true = 1 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> true OR true = 1 </p> </font> </b>";
}else{
echo "err";
}
}
if(isset($_POST['not'])){
$n1 = $_POST['input1'];
$n2 = $_POST['input2'];
if($n1 == 0 && $n2 == 0){
echo "<font color = 'red' size = '4'> <p> false : 1 , false : 1 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 0) {
echo "<font color = 'red' size = '4'> <p> true : 0 , false : 1 </p> </font> </b>";
}elseif ($n1 == 0 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> false : 1 , true : 0 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> true : 0 , true : 0 </p> </font> </b>";
}else{
echo "err";
}
}
?>
</form>
</body>
</html>
4. setelah itu buka browser anda ketik http://localhost/gerbanglogika/index.php
OK gaes sekian dulu tipsnya semoga bermanfaat buat kalian semua :-)
kali ini saya mau bagi tips coding program Gerbang Logika Matematika....
Mungkin dari kalian bingung dikasih tugas sama dosen kalian buat program ini tapi kalian sendiri tidak bisa membuatnya :-) nih saya agung pramadipta mau kasih caranya....
1. jangan lupa program xampp kalian dalam kondisi ON ya gan
2. buat file index.php pada folder C://xamp/htdoc/gerbanglogika/index.php
3. lalu isi scriptnya sebagai berikut
<!DOCTYPE html>
<html>
<head>
<title>TUGAS MATEMATIKA 4 GERBANG LOGIKA</title>
</head>
<link href ="style.css" rel="stylesheet" type="text/css">
<body>
<center>
<p> TUGAS UAS MATEMATIKA 4 </p>
<p> GERBANG LOGIKA </p>
<form method="post" action="">
<table border="1">
<table border = '3' cellspacing = '2' cellpadding = '10'
style = 'border : #aaa; color: #101; font-family : arial; fot-size : 12px;'>
<tr>
<td class="head"> INPUT 1 </td>
<td class="satu" width = '5' align = 'center' > : </td>
<td class="satu"> <select name="input1">
<option value="0">false</option>
<option value="1">true</option>
</select> </td>
</tr>
<tr>
<td class="head"> INPUT 2 </td>
<td class="dua" align = 'center'> : </td>
<td class="dua"> <select name="input2">
<option value="0">false</option>
<option value="1">true</option>
</select>
</tr>
<tr>
<td colspan="3" align="center">
<button type="submit" name="and">AND</button>
<button type="submit" name="or">OR</button>
<button type="submit" name="not">NOT</button>
</td>
</tr>
</form>
</table>
<?php
if(isset($_POST['and'])){
$n1 = $_POST['input1'];
$n2 = $_POST['input2'];
if($n1 == 0 && $n2 == 0){
echo "<font color = 'red' size = '4'> <p> false AND false = 0 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 0) {
echo "<font color = 'red' size = '4'> <p> true AND false = 0 </p> </font> </b>";
}elseif ($n1 == 0 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> false AND true = 0 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> true AND true = 1 </p> </font> </b>";
}else{
echo "err";
}
}
if(isset($_POST['or'])){
$n1 = $_POST['input1'];
$n2 = $_POST['input2'];
if($n1 == 0 && $n2 == 0){
echo "<font color = 'red' size = '4'> <p> false OR false = 0 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 0) {
echo "<font color = 'red' size = '4'> <p> true OR false = 1 </p> </font> </b>";
}elseif ($n1 == 0 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> false OR true = 1 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> true OR true = 1 </p> </font> </b>";
}else{
echo "err";
}
}
if(isset($_POST['not'])){
$n1 = $_POST['input1'];
$n2 = $_POST['input2'];
if($n1 == 0 && $n2 == 0){
echo "<font color = 'red' size = '4'> <p> false : 1 , false : 1 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 0) {
echo "<font color = 'red' size = '4'> <p> true : 0 , false : 1 </p> </font> </b>";
}elseif ($n1 == 0 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> false : 1 , true : 0 </p> </font> </b>";
}elseif ($n1 == 1 && $n2 == 1) {
echo "<font color = 'red' size = '4'> <p> true : 0 , true : 0 </p> </font> </b>";
}else{
echo "err";
}
}
?>
</form>
</body>
</html>
4. setelah itu buka browser anda ketik http://localhost/gerbanglogika/index.php
OK gaes sekian dulu tipsnya semoga bermanfaat buat kalian semua :-)
Komentar
Posting Komentar