'How can I call on a variable initialized from within an if statement? [duplicate]

For context I'm a first year It student. We are tasked to create a concept program for a payment system for our final project. We decided to do a payroll program. Here is a snippet of my code using JOptionFrame and JOptionPane

//Wages based on Job Position
    if (JobPositionComboBox.getSelectedItem().equals("Project Manager")){
        double wage = 350.f;
        jTextArea1.append("Total Salary this month : " + df.format(hour * wage) + "\n");
    }
    else if (JobPositionComboBox.getSelectedItem().equals("System Analyst")){
        double wage = 250.f;
        jTextArea1.append("Total Salary this month : " + df.format(hour * wage) + "\n");
    }
    else if (JobPositionComboBox.getSelectedItem().equals("System Developer")){
        double wage = 320.f;
        jTextArea1.append("Total Salary this month : " + df.format(hour * wage) + "\n");
    }
    else if (JobPositionComboBox.getSelectedItem().equals("Quality Assurance")){
        double wage = 220.f;
        jTextArea1.append("Total Salary this month : " + df.format(hour * wage) + "\n");
        
    
    } 
    jTextArea1.append("Payment Option : " + PaymentOptionComboBox.getSelectedItem() + "\n");
    jTextArea1.append("--------------------------------------------");
    
    
    //Payment option information prompts
    if (PaymentOptionComboBox.getSelectedItem().equals("Bank Account")){
       
    String ban = JOptionPane.showInputDialog(null, "Please enter your Bank Account Number", "Payment Option",JOptionPane.PLAIN_MESSAGE);
     int BAN = Integer.parseInt(ban);
        JOptionPane.showMessageDialog(null, "Transaction Information : " +
                "\nName : " + NameTextField.getText()  +
                "\nBank Account Number : " + BAN +        //I can't call on the wage inside the if statements, it just shows an error.
                "\nPayment Amount : " + df.format(hour * wage) +
                "\nPlease Confirm your information","Bank Account", JOptionPane.PLAIN_MESSAGE);
        ImageIcon BDO = new ImageIcon(SystemFrame.class.getResource("BDO.png"));
        JOptionPane.showMessageDialog(null,"Transaction Complete" + 
                "\nThank you for choosing our bank","Bank Account",JOptionPane.PLAIN_MESSAGE,BDO); 
}

Since the number assigned to the wage variable is dependent on the job position, I have to call it from within the if statements for the computation to be accurate. Does anybody have a solution?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source