In line 32 which is the lttr[ctr] = read.next().charAt(0); wont read all the letters that i input. it only reads the last letter that i entered. what should i do to be able to display all the letters i entered and be able to reverse there order so that they would act as a PUSH. Line 34 is required every after a letter was input by the user. and if you have another solution so that the user can use a 'Y' and 'N' as a reply instead of 1 or 0. Thanks
lttr --- is my array that reads the letter that the user inputs. it can only hold 10 arrays.
ctr --- is just for the loop.
package javaapplication4;
import java.util.*;
public class PushPop {
static Scanner read = new Scanner (System.in);
public static void main(String[] args) {
char letter;
char[] lttr = new char[10];
int ctr=0,again;
System.out.println ("Main Menu");
System.out.println ("A.Push");
System.out.println ("B.Pop");
System.out.println ("C.Print");
System.out.println ("D.exit");
System.out.print ("Please enter a letter:");
letter = read.next().charAt(0);
switch (letter)
{
case 'a':
case 'A':
System.out.println ("Push");
do
{
System.out.println ("Enter a letter:");
lttr[ctr] = read.next().charAt(0);
System.out.println ("Again? 1 for yes 0 for no");
again = read.nextInt();
}while (again>0);
for (ctr=lttr.length-1;ctr>=0;ctr--)
{
System.out.print (lttr[ctr]+" ");
}
break;
}
}
}