1. design the logic deciding whether to use AND or OR logic. write the decision
ID: 3808867 • Letter: 1
Question
1. design the logic deciding whether to use AND or OR logic. write the decision statement to identify when a discount should be offered and when a disocunt should not be offered.
2. be sure to include output statemens telling whether or not the customer is eligible for a discount.
3. compile and execute
// Airline.java - This program determines if an airline passenger is
// eligible for a 25% discount.
import javax.swing.*;
public class Airline
{
public static void main(String args[])
{
String passengerName = ""; // Passenger's name.
String ageString = ""; // String version of passenger's age.
int passengerAge = 0; // Passenger's age.
// This is the work done in the housekeeping() method
passengerName = JOptionPane.showInputDialog("Enter passenger's name: ");
ageString = JOptionPane.showInputDialog("Enter passenger's age: ");
passengerAge = Integer.parseInt(ageString);
// This is the work done in the detailLoop() method
// Test to see if this customer is eligible for a 25% discount.
// This is the work done in the endOfJob() method
System.exit(0);
}
}
Explanation / Answer
Hi Friend, You have not given the condition for 25% discount.
So i can not add exact logic. Based on age, i have decided whether customer is eligible for discount or not.
Please let me know in case of any issue.
//Airline.java - This program determines if an airline passenger is
//eligible for a 25% discount.
import javax.swing.*;
public class Airline
{
public static void main(String args[])
{
String passengerName = ""; // Passenger's name.
String ageString = ""; // String version of passenger's age.
int passengerAge = 0; // Passenger's age.
// This is the work done in the housekeeping() method
passengerName = JOptionPane.showInputDialog("Enter passenger's name: ");
ageString = JOptionPane.showInputDialog("Enter passenger's age: ");
passengerAge = Integer.parseInt(ageString);
// This is the work done in the detailLoop() method
// Test to see if this customer is eligible for a 25% discount.
if(passengerAge >= 45){
System.out.println("You are eligible for a 25% discount");
}else{
System.out.println("You are not eligible for a 25% discount");
}
// This is the work done in the endOfJob() method
System.exit(0);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.