3-7 LogicalAnd

posted Jan 27, 2014, 5:50 AM by Dlovan ismail   [ updated Jan 27, 2014, 5:53 AM by Karwan Jacksi ]

//This program demonstrates the logical && operator.

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

public class LogicalAnd 
{
    public static void main(String[] args)
    {
        double salary;                   // Annual salary
        double yearsOnJob;      // Years at current Job
        String input;                      // To hold string input
        
       // Get tho 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 uaer qualifies for the loan.
        if (salary >= 30000 && yearsOnJob >= 2) 
            JOptionPane.showMessageDialog(null, "You qualify " +"for the loan.");
        else
            JOptionPane.showMessageDialog(null, "You do not " +"qualify for the loan.");
        System.exit(0);   
    }   
}

ċ
LogicalAnd.java
(1k)
Karwan Jacksi,
Jan 27, 2014, 5:50 AM
Comments