Professional Documents
Culture Documents
Pertemuan : Pertama
NIM : A11.2018.11570
Nama : Suhaili Faruq
Hasil Program :
Source code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tugas PWL 1</title>
</head>
<body>
<?php
$UTS = 90;
$UAS = 80;
$tgs = 95;
$hasil = ($prosen_tgs+$prosen_UTS+$prosen_UAS);
echo "<table>";
echo "<tr><td>NIM</td><td>:</td><td>A11.2018.11570</td></tr>";
echo "<tr><td>Nama</td><td>:</td><td>Suhaili Faruq</td></tr>";
echo "<tr><td>Tugas</td><td>:</td><td>$tgs</td></tr>";
echo "<tr><td>UTS</td><td>:</td><td>$UTS</td></tr>";
echo "<tr><td>UAS</td><td>:</td><td>$UAS</td></tr>";
echo "<tr><td>Nilai</td><td>:</td><td>$hasil</td></tr>";
echo "<tr><td>Nilai Huruf</td><td>:</td><td>$ket</td></tr>";
echo "</table>";
echo "<br>\n";
echo "Keterangan";
echo "<ul>";
echo"<li>A >= 85</li>";
echo "<li>B 68.5 – 83.4</li>";
echo "<li>C 58.5 – 68.4</li>";
echo "<li>D 40 – 58.4</li>";
echo "<li>E < 40</li>";
echo "</ul>";
$biner = "";
$oktal = "";
$hexa = "";
$celcius = 0;
$celcius2 = 0;
$celcius3 = 0;
$celcius4 = 0;
$fahrenheit = 0;
$fahrenheit2 = 0;
$fahrenheit3 = 0;
$fahrenheit4 = 0;
$kelvin = 0;
$kelvin2 = 0;
$kelvin3 = 0;
$kelvin4 = 0;
$reamur = 0;
$reamur2 = 0;
$reamur3 = 0;
$reamur4 = 0;
$input = 0;
if(isset($_POST["huruf"])){
while($huruf != 0){
$hasilbagi = $huruf%2;
$biner .= (String)$hasilbagi;
$huruf = intval($huruf/2); #fungsi agar pembagian tidak koma
}
$biner = strrev($biner); #fungsi membalikkan String
while($huruf2 != 0){
$hasilbagi = $huruf2%8;
$oktal .= (String)$hasilbagi;
$huruf2 = intval($huruf2/8); #fungsi agar pembagian tidak koma
}
//$oktal .= (String)$huruf2;
$oktal = strrev($oktal); #fungsi membalikkan String4
while($huruf3 != 0){
$hasilbagi = $huruf3 % 16;
switch($hasilbagi){
case 0 : $hexa .= "0";break;
case 1 : $hexa .= "1";break;
case 2 : $hexa .= "2";break;
case 3 : $hexa .= "3";break;
case 4 : $hexa .= "4";break;
case 5 : $hexa .= "5";break;
case 6 : $hexa .= "6";break;
case 7 : $hexa .= "7";break;
case 8 : $hexa .= "8";break;
case 9 : $hexa .= "9";break;
case 10 : $hexa .= "A";break;
case 11 : $hexa .= "B";break;
case 12 : $hexa .= "C";break;
case 13 : $hexa .= "D";break;
case 14 : $hexa .= "E";break;
case 15 : $hexa .= "F";break;
default: break;
}
$huruf3 = intval($huruf3/16);
$hexa = strrev($hexa);
if(isset($_POST["value"])) {
?>
<BR>
<h3>Soal C</h3> <BR>
<form action="" method="post">
<table>
<tr><td><label>Masukan Angka Decimal : </label></td><td><input type="number" name
="huruf" id="decimal"></td></tr>
</table><br>
<button type="submit">Cek!</button>
</form>
<br>
<table border="1">
<tr><td><h3>Hasil Biner = </h3></td><td><h3><?php echo"$biner";?></h3></td></tr>
<tr><td><h3>Hasil Oktal = </h3></td><td><h3><?php echo"$oktal";?></h3></td></tr>
<tr><td><h3>Hasil Hexa = </h3></td><td><h3><?php echo"$hexa";?></h3></td></tr>
</table>
<BR>
<h3>Soal D</h3> <BR>
</table>
<button type="submit">Cek!</button>
</form>
<br><br>
<h3>Hasil :</h3><br>
<table border="1">
<tr><td>celcius : <?php echo"$celcius" ?></td><td>reamur : <?php echo"$reamur" ?>
</td><td>fahrenheit : <?php echo"$fahrenheit" ?></td><td>kelvin : <?php echo"$kel
vin" ?></td></tr>
<tr><td>reamur : <?php echo"$reamur2" ?></td><td>celcius : <?php echo "$celcius2"
?></td><td>fahrenheit : <?php echo"$fahrenheit2" ?></td><td>kelvin : <?php echo
"$kelvin2" ?></td></tr>
<tr><td>fahrenheit : <?php echo"$fahrenheit3" ?></td><td>reamur : <?php echo"$rea
mur3" ?></td><td>celcius : <?php echo "$celcius3" ?></td><td>kelvin : <?php echo"
$kelvin3" ?></td></tr>
<tr><td>kelvin : <?php echo"$kelvin4" ?></td><td>reamur : <?php echo"$reamur4" ?>
</td><td>fahrenheit : <?php echo"$fahrenheit4" ?></td><td>celcius : <?php echo"$c
elcius4" ?></td></tr>
</table>
</body>
</html>