/* * Assignment #6: Reverse Stack * Develop software to reverse the elements in a stack. * Print the stack before and after reversing the elements. * * Accepts a string (word), pushing the characters to * a stack while priting it out, then analyzes the stack * in reverse to determine if the word is an anagram */ package org.lurey.cs2b.assignments; import java.util.Stack; import java.util.Scanner; /** * Assignment for reversing java.util.Stack * @author Matan Lurey */ public class ReverseStack { /** * Program entry point * @param args the command line arguments */ public static void main(String[] args) { // Create a new stack object Stack stack = new Stack(); print("Stack (java.util.Stack) constructed..."); // Get a word print("Input a word: "); String word = new Scanner(System.in).nextLine(); print("Word inputted = " + word + "\nAdding to the stack..."); // Input to the stack for (int i=0, l=word.length(); i