Guest User

Untitled

a guest
Jun 25th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. /**********************************************************************
  2. **
  3. ** Programmer: Jayna Brisker Date: 02/11/2012 Course & Section: ECET370 B
  4. **
  5. ** Assignment: Week 6 Lab (Problem 3) keeping the stack order
  6. **
  7. ** File Name: Main.cpp
  8. **
  9. ** Description: all of the objects in a stack kept in order. Input:
  10. * Keyboard,mouse
  11. **
  12. ** Output: Screen, eclipse
  13. **
  14. **********************************************************************/
  15.  
  16. public class Main {
  17.  
  18. /**
  19. * @param args
  20. */
  21. public static void main(String[] args) {
  22. // TODO Auto-generated method stub
  23.  
  24. {
  25. Stack s = new Stack();
  26. Stack k = new Stack();
  27.  
  28. System.out.println("Insertion of 10 characters in s");
  29. for (int i = 0; i < 10; i++) {
  30. int x = 32 + (int) (Math.random() * 95);
  31. System.out.println(x + " --> " + (char) x);
  32. s.push((char) x);
  33.  
  34. }
  35. System.out.println("First Stack: " + s.peek());
  36.  
  37. for (int i = 1; i < 10; i++)
  38.  
  39. k.push(s.peek());
  40. s.pop();
  41.  
  42. System.out.println("New k stack " + k.peek());
  43. s.push(k.peek());
  44. k.pop();
  45. System.out.println("Tada!" + s.peek());
  46. if (s.isEmpty()) {
  47. System.out.println("Stack s is empty!!");
  48. }
  49.  
  50. }
  51. }
  52.  
  53. }
Add Comment
Please, Sign In to add comment