angeloeboy10

Untitled

Oct 16th, 2021
596
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.LinkedList;
  4. import java.util.Queue;
  5. import java.util.Scanner;
  6. import java.util.Stack;
  7.  
  8. public class StackTp {
  9.  
  10.     public static void main(String[] args) {
  11.         Scanner scanner = new Scanner(System.in);
  12.         Queue books = new LinkedList();
  13.         Stack bookStack = new Stack();
  14.  
  15.         System.out.println("Enter four book titles: ");
  16.  
  17.         System.out.print("Book 1: ");
  18.         String book1 = scanner.nextLine();
  19.         bookStack.push(book1);
  20.  
  21.         System.out.print("Book 2: ");
  22.         String book2 = scanner.nextLine();
  23.         bookStack.push(book2);
  24.  
  25.         System.out.print("Book 3: ");
  26.         String book3 = scanner.nextLine();
  27.         bookStack.push(book3);
  28.  
  29.         System.out.print("Book 4: ");
  30.         String book4 = scanner.nextLine();
  31.         bookStack.push(book4);
  32.  
  33.         books.offer(bookStack.pop());
  34.         books.offer(bookStack.pop());
  35.         books.offer(bookStack.pop());
  36.         books.offer(bookStack.pop());
  37.  
  38.         System.out.println("New order of books: ");
  39.         System.out.println(books);
  40.         System.out.println("Angelo Zuniga");
  41.     }
  42. }
  43.  
RAW Paste Data