Created
April 7, 2019 07:34
-
-
Save un-ro/2e5cbfe891590a74355500480d1c3f4e to your computer and use it in GitHub Desktop.
AAA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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