Program Konversi Suhu PHP

program konversi suhu php

Pada kesempatan ini kita akan membuat program konversi suhu. program ini termasuk kedalam program sederhana, karena hanya memasukkan proses aritmatika didalamnya.

#Tampilan

header.html:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Belajar Php</title>
<link rel="stylesheet" type="text/css" href="style.css" /> <!Memanggil style css>
</head>
<body>
<div id="sampul"> <!div id= membuat class css dengan nama header>


<div id="header">
<center><h2>Belajar PHP</h2></center>
<div id="linkHeader">
<h4><a href="index.php">Beranda</a></h4>
</div>
</div>
<div id="body">
<div id="SidebarKiri">

</div>
<div id="isi">

</body>
</html>


footer.html:

<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<body>
</div>
<div id="SidebarKanan">

</div>
</div>
<div id="footer">
<h2>Java Kita</h2>
</div>

</div>
</body>
</html>


style.css:

/*
Document : style
Created on : Sep 13, 2013, 3:27:50 PM
Author : Razaq
Description:
Purpose of the stylesheet follows.
*/

body{
background-color: #999999;
margin: 0px;
padding: 0px;
}

#sampul{ /*membuat class sampul di css */
margin: auto;
width: 900px;
clear: both; /*berhubungan dengan posisi text pada isi nanti */
text-align: center;
/*kita gunakan sampul supaya semuanya otomatis di tengah*/
}

#header{
height: 197px;
background-color: #0066ff;
padding: 20px;
text-align: left;
}

#linkHeader{
margin-top: 140px;
margin-left: 0;
text-align: left;

}

#body{
background-color: #cc0099;
clear: both;
display: table-row;

}

#SidebarKiri{
float: left;
width: 200px;
margin:0;
padding:10px;
border: 0;
clear: both;
background-color: #cc0099;
}
#isi{
float: left;
width: 440px;
margin:0;
padding:10px;
border: 0;
background-color: #cc00cc;
text-align: justify;
}
#SidebarKanan{
float: right;
width: 200px;
margin:0;
padding:10px;
border: 0;
background-color: #cc0099;
}

#footer{
height: 120px;
border: 0;
clear:both;
background-color: #9900cc;
padding: 20px;

}


#Program

footer.html:

<?php
include 'header.html';
?>
<form method="post">
<table border="0">
<tr>
<td>Masukkan Nilai Suhu: </td>
<td><input type="text" size="15" name="suhu" /></td>
<td><input type="submit" value="Proses" name="Proses"</td>
</tr>
</table>
</form>

<?php
if(isset($_POST['Proses'])){

$suhu = isset($_POST['suhu'])? $_POST['suhu']:NULL;
echo '<h3>Celcius</h3>';
echo 'Celsius = ';
echo $suhu;
echo '<br/>';
echo 'Kelvin = ';
echo $suhu + 273;
echo '<br/>';
echo 'Fahrenheit = ';
echo $suhu*1.8+32;

echo '<h3>Kelvin</h3>';
echo 'Kelvin = ';
echo $suhu;
echo '<br/>';
echo 'Celcius = ';
echo $suhu - 273.15;
echo '<br/>';
echo 'Fahrenheit = ';
echo $suhu * 1.8 - 459.67;

echo '<h3>Fahrenheit</h3>';
echo 'Fahrenheit = ';
echo $suhu;
echo '<br/>';
echo 'Celsius = ';
echo ($suhu-32)/1.8;
echo '<br/>';
echo 'Kelvin = ';
echo ($suhu+459.67)/1.4;;



}
?>
<?php
include 'footer.html';
?>

Outputnya seperti gambar di atas



Artikel Terkait:

0 comments:

Ada pertanyaan?? Silahkan tanyakan di kotak komentar .. :)