I am writing a Java program where the user enters in a sales amount and then they enter a code(1, 2, or a 3) and then the program calculates the commission based on the sales type(the code the user entered). It works for 1 and 3 but for some odd reason when I enter in a 2 for the code it does nothing, just closes even though the code is pretty much the same as 1 and 3. Any help would be appreciated.
public class TravelCommission extends Frame
{
static double dollars;
static double answer;
static int empCode;
static DecimalFormat df = new DecimalFormat("#.#");
public static void main(String[] args) 
{
    //Calling all methods
    dollars = getSales(0);
    empCode = getCode(0);
    answer = getCommission(dollars, empCode);
    output(dollars, answer);
    finish();
}
private static double getSales(double sales) 
{
    //Getting sales along with error checking and exception handeling
    try 
    {
        sales = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter in sales:", "Sales", JOptionPane.DEFAULT_OPTION));
        if(sales <= 0)
        {
            JOptionPane.showMessageDialog(null, "Please enter a value greater than 0.", "Error", JOptionPane.INFORMATION_MESSAGE);
        }
        else if(sales == JOptionPane.CANCEL_OPTION)
        {
            System.exit(0);
        }
        else
        {
        }
    } 
    catch (IllegalArgumentException e) 
    {
        JOptionPane.showMessageDialog(null, "Enter in a double value.", "Error!", JOptionPane.ERROR_MESSAGE);
    }
    return sales;
}
private static int getCode(int code)
{
    try 
    {
        code = Integer.parseInt(JOptionPane.showInputDialog(null, "Please enter the code for the type of sale\n1 = Telephone\n2 = In-store\n3 = Outdoor:", "Sales", JOptionPane.DEFAULT_OPTION));
        if(code <= 0 || code > 3)
        {
            JOptionPane.showMessageDialog(null, "Please enter a 1, 2, or 3.", "Error", JOptionPane.INFORMATION_MESSAGE);
        }
        else if(code == JOptionPane.CANCEL_OPTION)
        {
            System.exit(0);
        }
        else
        {
        }
    } 
    catch (IllegalArgumentException e) 
    {
        JOptionPane.showMessageDialog(null, "Please enter in a 1, 2, or 3.", "Error!", JOptionPane.ERROR_MESSAGE);
    }
    return code;
}
private static double getCommission(double dollars, int empCode) 
{
    //Determing the amount of commission made based off of the type of sale
    if(empCode == 1)
    {
        answer = dollars * 0.10;
    }
    else if(empCode == 2)
    {
        answer = dollars * 0.14;
    }
    else if(empCode == 3)
    {
        answer = dollars * 0.18;
    }
    return answer;
}
//Outputing the commission
public static int output(double dollars, double answer)
{
    JOptionPane.showMessageDialog(null, "Your total commission on sales of $" + dollars + " is $" + df.format(answer));
    return 0;
}
//Closes the program
public static void finish()
{
    System.exit(0);
    return;
}
}
 
    