Substitute Algorithm

BeforeAfter
class Account
{
    private static int chooseAccount()
    {

	char ans;
	int selection = -1;
	boolean more = true;

	while (more == true) {
	    System.out.println();
	    System.out.println("Select Account:");
	    System.out.println("s == savings");
	    System.out.println("c == chequing");
	    System.out.println("v == visa");
	    System.out.println("1 == extra account 1");
	    System.out.println("2 == extra account 2");
	    System.out.println("q == return to main menu");
	    System.out.println();
	    System.out.print("Please choose an option: ");

	    ans = (char)Console.in.readChar();
	    Console.in.readLine();

	    switch (ans)
	    {
	    case 's' :
	    case 'S' : selection = 0;
		       more = false;
		       break;

	    case 'c' : 
            case 'C' : selection = 1;
		       more = false;
		       break;

	    case 'v' : 
	    case 'V' : selection = 2;
		       more = false;
		       break;
 
            case '1' : selection = 3;
		       more = false;
		       break;
 
	    case '2' : selection = 4;
		       more = false;
		       break;

	    case 'q' : 
            case 'Q' : more = false;
		       break;

	    default : System.out.println();
		      System.out.println("Sorry, unrecognized request.");
		      System.out.print("Please try again, or type 'q' to quit");
	    }
	}
	return (selection);
    }
...
}
public class Display
{
    public char selectionScreen()
    {
	boolean more = true;
	char ans;
	
	do
	    {
		System.out.println();
		System.out.println("d == deposit");
		System.out.println("w == withdrawal");
		System.out.println("b == print balance");
		System.out.println("o == open account");
		System.out.println("c == close account");
		System.out.println("q == quit");
		System.out.println();
		System.out.print("Please choose an option: ");
		ans = (char)Console.in.readChar();
		Console.in.readLine();
		
		if(ans < 'a')
		    ans += ('a' - 'A');  //convert to lower case!
		
		if((ans == 'd') || (ans == 'w') || (ans == 'b') || (ans == 'o') || (ans == 'c') || (ans == 'q'))
		    more = false;
		
		else
		    {
			System.out.println();
			System.out.println("Sorry, unrecognized request.");
			System.out.println("Please try again, or type 'q' to quit");
		    } 
	    } while (more);
	return ans;
    }
...
}