Java Int Stack Driver
/*
* A simple client of the IntStack package.
*/
import java.util.Scanner;
class Driver {
public static void main(String[] args)
{
// Two test stacks.
IntStack s1 = new IntStack();
IntStack s2 = new IntStack();
// Input scanner.
Scanner in = new Scanner(System.in);
// Uh... A counter.
int cnt = 1;
// Read in integers until -1, and push each on one stack, and each
// times the input ordinal on the other.
int intin; // Integer read in.
do {
System.out.print("> ");
intin = in.nextInt();
if(intin != -1) {
s1.push(intin);
s2.push(cnt*intin);
++cnt;
}
} while(intin != -1);
// Pop 'em and print 'em
while(!s1.isEmpty()) {
int inout1 = s1.pop();
int inout2 = s2.pop();
System.out.println(inout1 + " " + inout2);
}
}
}