You are on page 1of 7

Mata Kuliah : Pemrograman Web Lanjut – TI – S1

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

echo "<h3>Soal A </h3><BR>\n";


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>Alamat</td><td>:</td><td>Desa Sungai Melawen RT 13 RW 4</td></t
r>";
echo "<tr><td>Nomor Telepon</td><td>:</td><td>085713561437</td></tr>";
echo "</table>";

echo "<h3>Soal B</h3> <BR>\n";

$UTS = 90;
$UAS = 80;
$tgs = 95;

$prosen_UAS= (0.2 * $UAS);


$prosen_UTS= (0.35 * $UTS);
$prosen_tgs= (0.45 * $tgs);

$hasil = ($prosen_tgs+$prosen_UTS+$prosen_UAS);

if($hasil >=85 && $hasil<=100){


$ket = "A";
}else if($hasil>=70 && $hasil<=84.9){
$ket = "B";
}else if($hasil>=60 && $hasil<=69.9){
$ket="C";
}else if($hasil >=50 && $hasil<=59.9){
$ket = "D";
}else{
$ket = "E";
}

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"])){

$huruf = $_POST["huruf"]; #fungsi untuk memasukan inputan dari form html ke P


HP
$huruf2 = $_POST["huruf"]; #fungsi untuk memasukan inputan dari form html ke
PHP
$huruf3 = $_POST["huruf"]; #fungsi untuk memasukan inputan dari form html ke
PHP

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"])) {

if(isset($_POST["suhu1"]) && $_POST["suhu1"] == "cl"){


$input = $_POST["value"];
$celcius = $input;
$fahrenheit = (1.8*$input)+32;
$reamur = 0.8 * $input;
$kelvin = $input + 273; }
if(isset($_POST["suhu2"]) && $_POST["suhu2"] == "rm"){
$input = $_POST["value"];
$celcius2 = 1.25*$input;
$fahrenheit2 = (2.25*$input)+32;
$reamur2 = $input;
$kelvin2 = 273+(1.25*$input); }

if(isset($_POST["suhu3"]) && $_POST["suhu3"] == "fr"){


$input = $_POST["value"];
$celcius3 = (5*($input-32))/9;
$fahrenheit3 = $input;
$reamur3 = (4*($input-32))/9;
$kelvin3 = ($input+ 459.67) / 1.8; }

if(isset($_POST["suhu4"]) && $_POST["suhu4"] == "kn"){


$input = $_POST["value"];
$celcius4 = $input - 273;
$fahrenheit4 = ($input*1.8)-459.67;
$reamur4 = (0.8*$input)-273;
$kelvin4 = $input; }
}

?>
<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>

<form action="" method ="post">


<table>
<tr><td><label>Masukan angka : </tr<label></td><td><input type="number" name="va
lue" id="decimal"></td></tr>
</table><br>
<table>
<tr><td><label>Ke Celcius </label></td><td><input type="checkbox" name="suhu1" va
lue="cl"></td></tr>

<tr><td><label>Ke Reamur </label></td><td><input type="checkbox" name="suhu2" val


ue="rm"></td></tr>

<tr><td><label>Ke Fahrenheit </label></td><td><input type="checkbox" name="suhu3"


value="fr"></td></tr>

<tr><td><label>Ke Kelvin </label></td><td><input type="checkbox" name="suhu4" val


ue="kn"></td></tr>

</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>

You might also like