3-7 LogicalAnd
Post date: Jan 27, 2014 1:50:42 PM
//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);
}
}