0% found this document useful (0 votes)
3 views4 pages

Java Stack Implementation Example

Praktik java

Uploaded by

Nur Ahla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Java Stack Implementation Example

Praktik java

Uploaded by

Nur Ahla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package praktik_stack;
import [Link];
import [Link];
/**
*
* @author user
*/
public class Stack3 {
private List<Object> list=new ArrayList<Object>();
private int currentIndex=-1;
int max=5;

public void push(Object object){


[Link](object);
currentIndex++;
}

public Object pop(){


Object object=[Link](currentIndex);
currentIndex--;
return object;
}
public int count (){
return [Link]();
}
public Object peek(){
return [Link](currentIndex);
}
public void clear(){
[Link]();
currentIndex=-1;
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package praktik_stack;

import [Link];

/**
*
* @author user
*/
public class Tgs_stack {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Stack3 bill = new Stack3();
String kalimat =" ";
String akhir= " ";
String Teks = " ";

[Link]("Input = ");
Scanner scan = new Scanner ([Link]);
kalimat = [Link]();
Object kata = [Link]("");
[Link](kata);

String angka = [Link]("[^0-9.]","");

int balik = [Link]();


for (int i = balik-1; i>=0; i--){
akhir = akhir+[Link](i);
}
[Link]("output : "+akhir);
}
}
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<select id="mySelect">
<option value ="1">pilihan 1</option>
<option value ="2">pilihan 2</option>
<option value ="3">pilihan 3</option>
</select>

<button onClick="getNilai()">Ambil Nilai</button>


<p id="hasil"></p>

<script>
function getNilai(){
var x = [Link]("mySelect").value;
//[Link](x);
[Link]("hasil").innerHTML = x;
}
</script>
</body>

<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<select id="pilihan">
<option value ="1">keliling persegi</option>
<option value ="2">luas persegi</option>
</select>

<input type="text" id="isi">meter


<button onClick ="hitungPersegi()">hitung hasil</button>
<div id="hasil"></div>

<script>
function hitungPersegi(){
var x = [Link]("pilihan").value;
var isi = [Link]("isi").value;
switch(x) {
case "1":
[Link]("hasil").innerHTML = isi*4;
break:

case "2":
[Link]("hasil").innerHTML = isi*isi;
break:
}
}
</script>
</body>

You might also like