Skip to content

Instantly share code, notes, and snippets.

@un-ro
Created April 7, 2019 07:34
Show Gist options
  • Select an option

  • Save un-ro/2e5cbfe891590a74355500480d1c3f4e to your computer and use it in GitHub Desktop.

Select an option

Save un-ro/2e5cbfe891590a74355500480d1c3f4e to your computer and use it in GitHub Desktop.
AAA
package minggu8;
import java.util.Scanner;
public class TestStack {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("Masukkan jumlah tumpukan: ");
int total = sc.nextInt();
Stack stack = new Stack(total);
int option = 0;
do {
menu();
option = sc.nextInt();
switch (option){
case 1:
System.out.print("Masukkan Data: ");
int data = sc.nextInt();
stack.Push(data);
break;
case 2:
stack.Pop();
break;
case 3:
stack.Print();
break;
}
} while (option != 4);
System.out.println();
stack.Print();
}
static void menu(){
System.out.println("Pilihan:" +
"\n\t1. Push" +
"\n\t2. Pop" +
"\n\t3. Print" +
"\n\t4. Exit");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment