3-3 LoanQualifier

posted Jan 19, 2014, 6:37 AM by Dlovan ismail   [ updated Jan 21, 2014, 12:38 PM by Karwan Jacksi ]

package loanqualifier;
import javax.swing.JOptionPane;    //  Needed for JOptionPane class

/*
3.3 Nested if Statements 
This program demonstrates a nested if statement.
*/

public class LoanQualifier {

   
    public static void main(String[] args) {
         
        double salary;                       // Annual salary
        double yearsOnJob;          // Years at current job
        String input;                          // To hold string input
        
        // Get the user's annual salary.
        input = JOptionPane.showInputDialog("Enter your "+"annual salary.");
        salary = Double.parseDouble(input);
        
        // Get the number of years at the current job.
        input =JOptionPane.showInputDialog("Enter the number of "+"years at your current job.");
        yearsOnJob = Double.parseDouble(input);
        
       // Determine whether the user qualifies for the loan.
        if (salary >= 30000)
        {
            if (yearsOnJob >= 2)
            {
                JOptionPane.showMessageDialog(null, "You qualify"+"for the loan.");
            }
            else
            {
                JOptionPane.showMessageDialog(null, "You must have " + "been on your current job for at least "+"two years to qualify.");
                          
            }
        }
        else
        {
            JOptionPane.showMessageDialog(null, "You must earn " + "at least $30,000 per year to qualify.");
                                                                                                                          
        }

           System.exit(0);
    }    
}

ċ
LoanQualifier.java
(2k)
Karwan Jacksi,
Jan 19, 2014, 6:37 AM
Comments