Kamis, 24 Mei 2012

Program Web Menghitung Bangun Ruang



<?php
/*
Contoh program php untuk perhitungan
Silakan edit sesuai kebutuhan
*/
require_once "HTML/Form.php";

//Variabel judul program contoh: Menghitung Luas Lingkaran
$judul = "Menghitung Volume Tabung";

//Fungsi perhitungan/rumus luaslingkaran
function volumetabung ($r , $t ){
                $v = M_PI * pow($r, 2) * $t ;
                $v = round($v, 2);
                return $v;
}

$form = new HTML_Form('index.php');

//Form masukkan awal yaitu jari
$form->addText("jari", "Berapa jari-jari tabung (cm)?");
$form->addText("tinggi", "Berapa tinggi tabung (cm)?");

/*
Tambahkan bila parameter lebih dari satu
$form->addText("diameter", "Berapa diameter lingkarannya (cm)?");
*/

$form->addSubmit("submit", "Submit");

?>
<!DOCTYPE html>
<html>
<head>
                <title><?php echo $judul; ?></title>
                <style type="text/css">
                                html, body{
                                                font-family: Arial;
                                                background:red;
                                                border: 7;
                                                margin: 9;
                                                outline: 7;
                                                padding: 5;
                                                background:url(KAGAYA009.jpg);                                            
                                                }
                                #header,#footer,#content div,#content table {width:500px;margin: 0px auto;text-align:center; color:#FFFFFF;}
                                #content table th{width:25000px;}
                                #content table td{width:25000px;}
                                #content{margin:10em 0;
                                background-color:#0033CC;
                                color:#FFFFFF;
                                font-size:24px;
                                }
                               
                </style>
                  
</head>
<body>
<table width="1670" border="0">
  <tr>
    <td background="KAGAYA006.jpg" width="200" height="735">&nbsp;</td>
    <td background="KAGAYA003.jpg" width="1400">&nbsp;>
      <div id="header"><h1><?php echo $judul; ?></h1></div>
                <div id="content">
                <?php if (isset($_GET["submit"])){
                                //Mengambil nilai jari-jari($r) dari masukkan $_GET["jari"]
                                $jari=$_GET["jari"];
                                $tinggi=$_GET["tinggi"];
                                //Menampilkan masukkan dan hasil perhitungan
                                echo "<div>Jari-jari : $jari cm<sup>2</sup></div>
                                                  <div>tinggi : $tinggi cm</div>
                                                                <div>Volumenya : ".volumetabung($jari, $tinggi)." cm<sup>2</sup></div>
                                                                <div><< <a href='index.php'>back to form</a></div>";
                }else{
                                $form->display();
                }?>
<center>Masukkan Nilai Yang akan dihitung</center>  
<p> <center>
                </center></p>
</div>
                <div id="footer">
                                Copyright 2012 _Kelompok1_XITKJ2
                                _SMK N 2 Kota Tasikmalaya
                </div>

</table><table width="2355" border="900">
  <tr>
    <td width="1">&nbsp;</td>
    <td width="1">&nbsp;</td>
    <td width="833">&nbsp;</td>
  </tr>
</table>
</td>
    <td background="KAGAYA006.jpg" width="200">&nbsp;</td>
  </tr>
</table>
</body>
</html>