Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**********************************************************************
- **
- ** Programmer: Jayna Brisker Date: 02/11/2012 Course & Section: ECET370 B
- **
- ** Assignment: Week 6 Lab (Problem 3) keeping the stack order
- **
- ** File Name: Main.cpp
- **
- ** Description: all of the objects in a stack kept in order. Input:
- * Keyboard,mouse
- **
- ** Output: Screen, eclipse
- **
- **********************************************************************/
- public class Main {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- {
- Stack s = new Stack();
- Stack k = new Stack();
- System.out.println("Insertion of 10 characters in s");
- for (int i = 0; i < 10; i++) {
- int x = 32 + (int) (Math.random() * 95);
- System.out.println(x + " --> " + (char) x);
- s.push((char) x);
- }
- System.out.println("First Stack: " + s.peek());
- for (int i = 1; i < 10; i++)
- k.push(s.peek());
- s.pop();
- System.out.println("New k stack " + k.peek());
- s.push(k.peek());
- k.pop();
- System.out.println("Tada!" + s.peek());
- if (s.isEmpty()) {
- System.out.println("Stack s is empty!!");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment