Selasa, 29 Mei 2012

Tugas Pemrograman Web 3

Berikut adalah Tugas Pemrograman Web ke 3 kelompok kami, dengan Anggota:
1. Ridwan H Haris [11018080]
2. Danis Toga Setiawan [11018072]
3. Ismu Nugraha [11018087]
4. Taufik Irawan [11018076]
5. MZ Ridwan Firdaus [11018084]





1. Buatlah form input x & y seperti materi kemarin Setelah di proses maka akan menampilkan nilai yang terbesar seperti materi kemarin

jawaban:
sourcecode html:


<html>
<head>
<title>Tugas P.Web No. 1</title>
</head>

<body background="1.jpg">
<br>
<form action="http://localhost/1.asp" method="post" target="_blank">
<table align="center" >
<tr>
 <td colspan="3" align="center">Menentukan Nilai Yang Terbesar</td>
</tr>
<tr>
 <td colspan="3">=================================</td>
</tr>
<tr>
 <td>Nilai X</td>
 <td>:</td>
 <td><input type="text" size="30" name="x"></td>
</tr>
<tr>
 <td>Nilai Y</td>
 <td>:</td>
 <td><input type="text" size="30" name="y"></td>
</tr>
<tr>
 <td><input type="submit" value="Ok?"></td>
</tr>

</table>

</body>
</html>


sourcecode asp:

<%
dim x,y;

x=request.form('x');
y=request.form('y');

response.write("Nilai x : " x);
response.write("Nilai y : " y);
response.write("<br>");

if(x>y){
response.write "Nilai X lebih besar dari nilai Y";
}else if(y>x){
response.write "Nilai y lebih besar dari nilai x";
}else response.write "Nilai x & y sama";

%>

screenshoot nya :















2. Buatlah aplikasi perulangan dengan FOR,WHILE, DO WHILE (menggunakan PHP / ASP)
jawaban:

sourcecode html :


<html>
<head>
<title>Tugas P.Web No. 2</title>
</head>

<body background="2.jpg"">
<br>
<form action="http://localhost/2.php" method="post" target="_blank">
<table align="center" >
<tr>
 <td colspan="3" align="center">Proses Perulangan</td>
</tr>
<tr>
 <td colspan="3">=================================</td>
</tr>
<tr>
 <td>Masukan kata</td>
 <td>:</td>
 <td><input type="text" size="30" name="x"></td>
</tr>
<tr>
 <td>Ulang selama</td>
 <td>:</td>
 <td><input type="text" size="30" name="y"></td>
</tr>
<tr>
 <td><input type="submit" value="Ok?"></td>
</tr>
</table>

<form action="http://localhost/2.php" method="post" target="_blank">
<table align="center" >
<tr>
 <td colspan="3" align="center">Proses Perpangkatan</td>
</tr>
<tr>
 <td colspan="3">=================================</td>
</tr>
<tr>
 <td>Masukan Angka</td>
 <td>:</td>
 <td><input type="text" size="30" name="kali"></td>
</tr>
<tr>
 <td>Pangkat</td>
 <td>:</td>
 <td><input type="text" size="30" name="dengan"></td>
</tr>
<tr>
 <td><input type="submit" value="Ok?"></td>
</tr>

</table>

<form action="http://localhost/2.php" method="post" target="_blank">
<table align="center" >
<tr>
 <td colspan="3" align="center">Proses Faktorial</td>
</tr>
<tr>
 <td colspan="3">=================================</td>
</tr>
<tr>
 <td>Masukan Angka</td>
 <td>:</td>
 <td><input type="text" size="30" name="fak"></td>
</tr>
<tr>
 <td><input type="submit" value="Ok?"></td>
</tr>

</table>

</body>
</html>


sourcecode php:

<?php

$x=$_POST["x"];
$y=$_POST["y"];
$kali=$_POST["kali"];
$dengan=$_POST["dengan"];
$fak=$_POST["fak"];

echo "<h2>";
echo "Menggunakan Proses For";
echo "</h2>";

echo "Kata yg dimasukan: ".$x." dan Nilai Ulang: " .$y."<br>";
for($i=0;$i<$y;$i++){
 echo $x;
 echo "<br>";
 }

echo "<h2>";
echo "Menggunakan Proses While";
echo "</h2>";

$i=0;
$hasil=1;
while($i<$dengan)
{
 $hasil=$hasil*$kali;
 $i++;
}
echo $kali." dipangkat ".$dengan." = ".$hasil;
echo "<br>";

echo "<h2>";
echo "Menggunakan Proses Do While";
echo "</h2>";
$hasil=1;
$i=0;
do
{
 $hasil=$fak*($fak-1);
 $i++;
}
while ($i<$fak);
echo $fak." faktorial = ".$hasil;
echo "<br>";

?>
 
screenshoot nya :
 
 

 
 
 
 
setelah diinputkan : 
 
 

 
 

3. Buatlah aplikasi yang menggunakan fungtion PHP (min 5 function)
jawaban:

sourcecode :

<html>

<head>
<title>Tugas P.Web No. 3</title>
</head>
<body>

<?php
$x=20;
$y=5;

echo "<h2>Angka Pertama: ".$x. "</h2>";
echo "<h2>Angka Kedua  : ".$y. "</h2>";

function pengurangan($x,$y)
{
$total=$x-$y;
return $total;
}
echo "1. Fungsi Pengurangan: <br>";
echo $x. " - " .$y. " = " . pengurangan($x,$y);
echo "<br><br>";

function tambahan($x,$y)
{
$total=$x+$y;
return $total;
}
echo "2. Fungsi Penambahan: <br>";
echo $x. " + " .$y. " = " . tambahan($x,$y);
echo "<br><br>";

function bagian($x,$y)
{
$total=$x/$y;
return $total;
}
echo "3. Fungsi Pembagian: <br>";
echo $x. " : " .$y. " = " . bagian($x,$y);
echo "<br><br>";

function perkalian($x,$y)
{
$total=$x*$y;
return $total;
}
echo "4. Fungsi Perkalian: <br>";
echo $x. " x " .$y. " = " . perkalian($x,$y);
echo "<br><br>";

function faktorial($x)
{
$total=$x*($x-1);
return $total;
}
echo "5. Fungsi Faktorial: <br>";
echo $x. " faktorial = " . faktorial($x);
echo "<br><br>";

?>

</body>
</html>
 
 

 


0 komentar:

Posting Komentar