/* Write a program to sort a stack in ascending order You should not make any assumptions about how the stack is 
implemented The following are the only functions that should be used to write this program: push | pop | peek | isEmpty
 */
 

@@ -1,8 +1,79 @@
+package edu.java;%0A%0Aimport java.util.Iterator;%0Aimport java.util.Stack;%0A%0A
 /* Write
@@ -148,16 +148,18 @@
 y assump
+- 
 tions ab
@@ -304,10 +304,968 @@
 pty%0A */%0A
- 
+%0Apublic class SortStack %7B%0A%09%0A%09public static Stack%3CInteger%3E t = new Stack%3CInteger%3E ();%0A%09%0A%09public static void sorted(Stack%3CInteger%3E s, int num)%7B%0A%09%09int result = s.pop();%0A%09%09for(int i = 0; i%3Cnum;i++)%7B%0A%09%09%09int temp = s.pop();%0A%09%09%09if(temp %3C result)%7B%0A%09%09%09%09int tran = result;%0A%09%09%09%09result = temp;%0A%09%09%09%09temp = tran;%0A%09%09%09%09t.push(temp);%0A%09%09%09%7D else%7B%0A%09%09%09%09t.push(temp);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09/*%0A%09%09Iterator it = t.iterator();%0A%09%09%0A%09%09System.out.println(%22!%22+t.size());%0A%09%09while(it.hasNext())%7B%0A%09%09%09System.out.print(it.next()+%22 %22);%0A%09%09%7D%0A%09%09*/%0A%09%09s.push(result);%0A%09%09int size = t.size();%0A%09%09for(int i = 0; i%3Csize;i++)%7B%0A%09%09%09s.push(t.pop());%0A%09%09%7D%0A%09%09t.clear();%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09Stack%3CInteger%3E s = new Stack%3CInteger%3E ();%0A%09%09s.push(1);%0A%09%09s.push(4);%0A%09%09s.push(3);%0A%09%09s.push(7);%0A%09%09s.push(6);%0A%09%09s.push(2);%0A%09%09%0A%09%09for(int i = 5;i%3E0;i--)%7B%0A%09%09sorted(s,5);%0A%09%09%7D%0A%09%09%0A%09%09Iterator it = s.iterator();%0A%09%09System.out.println(%22%5Cn%22+s.size());%0A%09%09while(it.hasNext())%7B%0A%09%09%09System.out.print(%22?%22+it.next());%0A%09%09%7D%0A%09%7D%0A%0A%7D
 %0A

Update SortStack.java