<html>
<head>
<title>Contoh Implementasi Push dan POP pada Stack</title>
</head>
<body>
<script type="text/javascript">
var stack = new Array;
stack.push("A");
stack.push("B");
stack.push("C");
document.write("stack:"+stack.toString() +"<br>");
var YangDiAmbil = stack.pop();
document.write("Data Yang Diambil:"+YangDiAmbil);
document.write("<br>");
document.write("Isi Stack Terakhir:"+stack.toString());
</script>
</body>
</html>
Sabtu, 18 April 2009
STACK Praktek ke 2
lt;html>
<head>
<title>Struktur Fata stack</title>
<script language = "JavaScript">
var stack = new Array();
function Input_ke_Stack(data) {
stack.push(data);
}
function Ambil_dari_Stack() {
var data_dari_stack = stack.pop();
if (data_dari_stack == undefined)
return "Stack Sudah Kosong";
else
return data_dari_stack;
}
function TampilkanStack(list) {
list.options.length = 0;
for (var i = 0; i < stack.length; i++) {
var data = new Option(stack[i]);
list.options[list.options.length] = data;
}
}
</script>
</head>
<body>
<form>
<input type=text name=textSimpan>
<input type=button value="Masukan ke Stack"
onClick='Input_ke_Stack(textSimpan.value);
textSimpan.value="";
TampilkanStack(mediaList);'>
<select name="mediaList" size=12>
<option>Tampilan data....
</select>
<input type=text name=textAmbil size=20>
<input type=button value="Ambil dari Stack"
onClick="textAmbil.value = Ambil_dari_Stack();
TampilkanStack(mediaList);">
</form>
</body>
</html>
<head>
<title>Struktur Fata stack</title>
<script language = "JavaScript">
var stack = new Array();
function Input_ke_Stack(data) {
stack.push(data);
}
function Ambil_dari_Stack() {
var data_dari_stack = stack.pop();
if (data_dari_stack == undefined)
return "Stack Sudah Kosong";
else
return data_dari_stack;
}
function TampilkanStack(list) {
list.options.length = 0;
for (var i = 0; i < stack.length; i++) {
var data = new Option(stack[i]);
list.options[list.options.length] = data;
}
}
</script>
</head>
<body>
<form>
<input type=text name=textSimpan>
<input type=button value="Masukan ke Stack"
onClick='Input_ke_Stack(textSimpan.value);
textSimpan.value="";
TampilkanStack(mediaList);'>
<select name="mediaList" size=12>
<option>Tampilan data....
</select>
<input type=text name=textAmbil size=20>
<input type=button value="Ambil dari Stack"
onClick="textAmbil.value = Ambil_dari_Stack();
TampilkanStack(mediaList);">
</form>
</body>
</html>
Record Data Pegawai
<html>
<head><title>Memanipulasi Data Pegawai</title>
<script language = "javascript" type="text/javascript">
<!--
var DBPegawai = new Array();
function Pegawai( Fields_NIP,
Fields_Nama,
Fields_Gaji_Per_Jam,
Fields_Jam_Kerja
Fields_Gaji_Total)
{
this.NIP = Fields_NIP;
this.Nama = Fields_Nama;
this.Gaji_Jam = Fields_Gaji_Per_Jam;
this.Jam_kerja = Fields_Jam_Kerja;
this.Gaji_Total = Fields_Gaji_Total;
}
function inputPegawai()
{
var Nama,Gaji_Per_Jam, Jam_Kerja, Gaji ;
while ( NIP = window.prompt("Ketikan NIP (Nomor Induk Pegawai)
\n\n Click 'cancel' untuk Berhenti !!.") )
{
Nama = window.prompt( "Nama Pegawai :" ) ;
gaji_Per_Jam = parselnt(window.prompt( "Gaji Per Jam :" )) ;
Jam_Kerja = Parselnt(window.prompt( "jumlah Jam Kerja :" )) ;
Gaji = Gaji_Per_jam * Jam_Kerja;
DBPegawai[DBPegawai.length] = new Pegawai(NIP,Nama,Gaji_Per_jam,Jam_Kerja,Gaji );
}
ShowPegawai();
}
function ShowPegawai(){
document.write("<table border='1'>" +
"<tr>" +
"<th>NIP</th><th>Nama</th><th>Gaji Per Jam</th><th>Jam Kerja</th>"+
"<th>Gaji Total</th>" +
"</tr>");
for (i=0; i < DBPegawai.length; i++) {
document.write("<tr>" +
" <td>" + DBPegawai[i].NIP + "</td>
" <td>" + DBPegawai[i].Nama + "</td>" +
" <td align='right'>" + DBPegawai[i].Gaji_Jam + "</td>" +
" <td align='right'>" + DBPegawai[i].Jam_Kerja + "</td>" +
" <td align='right'>" + DBPegawai[i].Gaji_Total + "</td>" +
"</tr>");
}
document.write( " </table>");
}
//-->
</script>
</head>
<body onload ="inputpegawai();">
</body>
</html>
<head><title>Memanipulasi Data Pegawai</title>
<script language = "javascript" type="text/javascript">
<!--
var DBPegawai = new Array();
function Pegawai( Fields_NIP,
Fields_Nama,
Fields_Gaji_Per_Jam,
Fields_Jam_Kerja
Fields_Gaji_Total)
{
this.NIP = Fields_NIP;
this.Nama = Fields_Nama;
this.Gaji_Jam = Fields_Gaji_Per_Jam;
this.Jam_kerja = Fields_Jam_Kerja;
this.Gaji_Total = Fields_Gaji_Total;
}
function inputPegawai()
{
var Nama,Gaji_Per_Jam, Jam_Kerja, Gaji ;
while ( NIP = window.prompt("Ketikan NIP (Nomor Induk Pegawai)
\n\n Click 'cancel' untuk Berhenti !!.") )
{
Nama = window.prompt( "Nama Pegawai :" ) ;
gaji_Per_Jam = parselnt(window.prompt( "Gaji Per Jam :" )) ;
Jam_Kerja = Parselnt(window.prompt( "jumlah Jam Kerja :" )) ;
Gaji = Gaji_Per_jam * Jam_Kerja;
DBPegawai[DBPegawai.length] = new Pegawai(NIP,Nama,Gaji_Per_jam,Jam_Kerja,Gaji );
}
ShowPegawai();
}
function ShowPegawai(){
document.write("<table border='1'>" +
"<tr>" +
"<th>NIP</th><th>Nama</th><th>Gaji Per Jam</th><th>Jam Kerja</th>"+
"<th>Gaji Total</th>" +
"</tr>");
for (i=0; i < DBPegawai.length; i++) {
document.write("<tr>" +
" <td>" + DBPegawai[i].NIP + "</td>
" <td>" + DBPegawai[i].Nama + "</td>" +
" <td align='right'>" + DBPegawai[i].Gaji_Jam + "</td>" +
" <td align='right'>" + DBPegawai[i].Jam_Kerja + "</td>" +
" <td align='right'>" + DBPegawai[i].Gaji_Total + "</td>" +
"</tr>");
}
document.write( " </table>");
}
//-->
</script>
</head>
<body onload ="inputpegawai();">
</body>
</html>
Analisis Deret Fibonacci
<html>
<head>
<script>
<!--
function fibonacci(n){
var i;
var array_fib = new Array();
array_fib.push(0);
array_fib.push(1);
for(i=0; i<n; i++) {
array_fib.push(array_fib[0] + array_fib[1]);
array_fib.shift();
}
return array_fib[0];
}
for(i=0; i<=20; i++
document.write("Fibonacci(" + i + ") = " + fibonacci(i) + "<br>");
//-->
</script>
</head>
<body>
</body>
</html>
<head>
<script>
<!--
function fibonacci(n){
var i;
var array_fib = new Array();
array_fib.push(0);
array_fib.push(1);
for(i=0; i<n; i++) {
array_fib.push(array_fib[0] + array_fib[1]);
array_fib.shift();
}
return array_fib[0];
}
for(i=0; i<=20; i++
document.write("Fibonacci(" + i + ") = " + fibonacci(i) + "<br>");
//-->
</script>
</head>
<body>
</body>
</html>
Parameter Array
<HTML>
<HEAD>
<TITLE>Parameter Array</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var tempat = []);
var data = prompt("Ketik Jumlah Maksimum Array :");
for (m=1; m<=data; m++)
{
var bil = prompt("Masukan Bilangan :" )
tempat[m]= bil;
}
for (n=1; n<=data; n++)
{
document.write("Elemen Array ("+n+") =" +tempat[n] + "<BR>");
}
//-->
</SCRIPT>
</BODY>
</HTML>
<HEAD>
<TITLE>Parameter Array</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var tempat = []);
var data = prompt("Ketik Jumlah Maksimum Array :");
for (m=1; m<=data; m++)
{
var bil = prompt("Masukan Bilangan :" )
tempat[m]= bil;
}
for (n=1; n<=data; n++)
{
document.write("Elemen Array ("+n+") =" +tempat[n] + "<BR>");
}
//-->
</SCRIPT>
</BODY>
</HTML>
MODUL II ARRAY
<HTML>
<HEAD>
<TITLE>Belajar Array</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var DATA_KU = new Array("Saya","Sedang","bingung belum bayar UTS");
for (i=0; i<3; i++)
{
document.write(DATA_KU[i] +"<br>");
}
alert ("Selamat Belajar Struktur Data");
alert ("Semoga Memperoleh Ilmu Yang Bermanfaat");
alert ("Amiiiin");
//-->
</SCRIPT>
</BODY>
</HTML>
<HEAD>
<TITLE>Belajar Array</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var DATA_KU = new Array("Saya","Sedang","bingung belum bayar UTS");
for (i=0; i<3; i++)
{
document.write(DATA_KU[i] +"<br>");
}
alert ("Selamat Belajar Struktur Data");
alert ("Semoga Memperoleh Ilmu Yang Bermanfaat");
alert ("Amiiiin");
//-->
</SCRIPT>
</BODY>
</HTML>
tipe data
<HTML>
<HEAD>
<TITLE>Membuat Fungsi Matematika Dengan JavaScript</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
<
!--
function jumlah(x, y) {
var hasil = x + y;
return(hasil);
}
var a = parselnt(prompt("Ketikan Bilangan A = \n Ingat Jangan String"));
var b = parselnt(prompt("Ketikan Bilangan B = \n Ingat Jangan String"));
var z = jumlah(a,b);
document.write(z);
document.write("<BR>");
document.write("<hr>";
document.write("Tipe Data nya adalah = " + typeof(z));
//-->
</SCRIPT>
</BODY>
</HTML>
<HEAD>
<TITLE>Membuat Fungsi Matematika Dengan JavaScript</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
<
!--
function jumlah(x, y) {
var hasil = x + y;
return(hasil);
}
var a = parselnt(prompt("Ketikan Bilangan A = \n Ingat Jangan String"));
var b = parselnt(prompt("Ketikan Bilangan B = \n Ingat Jangan String"));
var z = jumlah(a,b);
document.write(z);
document.write("<BR>");
document.write("<hr>";
document.write("Tipe Data nya adalah = " + typeof(z));
//-->
</SCRIPT>
</BODY>
</HTML>
Tipe Data
<HTML>
<HEAD>
<TITLE>Konversi Antar Sistem Bilangan</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var bil = new Number(25);
document.write("Bilangan Desimal: " +bil + "<BR>");
document.write(""<HR>");
document.write("Biner : " + bil.toString(2) + "<BR>");
document.write("Oktal : " + bil.toString(8) + "<BR>");
document.write("Heksa : " + bil.toString(16) +
//-->
</SCRIPT>
</BODY>
</HTML>
<HEAD>
<TITLE>Konversi Antar Sistem Bilangan</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var bil = new Number(25);
document.write("Bilangan Desimal: " +bil + "<BR>");
document.write(""<HR>");
document.write("Biner : " + bil.toString(2) + "<BR>");
document.write("Oktal : " + bil.toString(8) + "<BR>");
document.write("Heksa : " + bil.toString(16) +
//-->
</SCRIPT>
</BODY>
</HTML>
MODUL I Tipe Data
<html>
<head>
<title> type bilangan</title>
</head>
<body>
<script language = "javascript">
<!--
var a = 15;
b = 14;
tambah = a + b;
kali = a * b;
document.write("Penambahan (" +a+ " + " +b+ ") = " + tambah);
document.write("<BR>")
document.write("Perkalian (" +a+ " * " +b+ ") = " + kali );
document.write("<BR>");
//-->
</script>
</body>
</html>
<head>
<title> type bilangan</title>
</head>
<body>
<script language = "javascript">
<!--
var a = 15;
b = 14;
tambah = a + b;
kali = a * b;
document.write("Penambahan (" +a+ " + " +b+ ") = " + tambah);
document.write("<BR>")
document.write("Perkalian (" +a+ " * " +b+ ") = " + kali );
document.write("<BR>");
//-->
</script>
</body>
</html>
Perkenalan Struktur Data
<HTML>
<HEAD>
<TITLE>MODUL KE-1 </TITLE>
<Script Language = "JavaScript>
<!-->
alert("Wilujeng Sumping kang dedi");
//-->
</Script>
</HEAD>
<Body by Color = ooffoo>
<P> Selamat Datang Kang Dedi
<HR> <font color = "RED">
<HI> STMIK KHARISMA KARAWANG</HI></font>
</Script>
</Body>
</HTML>
<HEAD>
<TITLE>MODUL KE-1 </TITLE>
<Script Language = "JavaScript>
<!-->
alert("Wilujeng Sumping kang dedi");
//-->
</Script>
</HEAD>
<Body by Color = ooffoo>
<P> Selamat Datang Kang Dedi
<HR> <font color = "RED">
<HI> STMIK KHARISMA KARAWANG</HI></font>
</Script>
</Body>
</HTML>
Langganan:
Postingan (Atom)