3-8 LogicalOr
Post date: Jan 27, 2014 2:00:50 PM
//This program demonstrates the logical || operator.
package logicalor;
import javax.swing.JOptionPane; // Needed for JOptionPane class
public class LogicalOr
{
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 qualities (or 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);
}
}