Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.LinkedList;
- import java.util.Queue;
- import java.util.Scanner;
- import java.util.Stack;
- public class StackTp {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Queue books = new LinkedList();
- Stack bookStack = new Stack();
- System.out.println("Enter four book titles: ");
- System.out.print("Book 1: ");
- String book1 = scanner.nextLine();
- bookStack.push(book1);
- System.out.print("Book 2: ");
- String book2 = scanner.nextLine();
- bookStack.push(book2);
- System.out.print("Book 3: ");
- String book3 = scanner.nextLine();
- bookStack.push(book3);
- System.out.print("Book 4: ");
- String book4 = scanner.nextLine();
- bookStack.push(book4);
- books.offer(bookStack.pop());
- books.offer(bookStack.pop());
- books.offer(bookStack.pop());
- books.offer(bookStack.pop());
- System.out.println("New order of books: ");
- System.out.println(books);
- System.out.println("Angelo Zuniga");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement