Here you go as requested I have provided the code with
appropriate comments and variable names.
If there is any further query kindly add it as a comment.
Note: here I have used the logical OR represented by || in the if condition
******************************************************************
You can either add these lines after the comment
// This is the work done in detailLoop() method
// Test to see if this customer is eligible for a 25% discount
******************************************************************
System.out.println("Customer Name: " + passengerName);
System.out.println("Customer Age: " + passengerAge);
// This is the conditional statement which checks if the passengerAge is lesser
// than or equal to 6 or if the passenger's age is greater than or equal to 65.
if ((passengerAge <= 6) || (passengerAge >= 65)) {
System.out.println("Passenger is eligible for a discount");
} else {
System.out.println("Passenger is not eligible for a discount");
}
*****************************************************************
This is the complete code with the above changes
*****************************************************************
//Airline.java - This program determines if an airline passenger is
//eligible for a 25% discount.
import java.util.Scanner;
public class Airline {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
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
System.out.println("Enter passenger's name: ");
passengerName = s.nextLine();
System.out.println("Enter passenger's age: ");
ageString = s.nextLine();
passengerAge = Integer.parseInt(ageString);
// This is the work done in detailLoop() method
// Test to see if this customer is eligible for a 25% discount
System.out.println("Customer Name: " + passengerName);
System.out.println("Customer Age: " + passengerAge);
// This is the conditional statement which checks if the passengerAge is lesser
// than or equal to 6 or if the passenger's age is greater than or equal to 65.
if ((passengerAge <= 6) || (passengerAge >= 65)) {
System.out.println("Passenger is eligible for a discount");
} else {
System.out.println("Passenger is not eligible for a discount");
}
// This is the work done in endOfJob() method
System.exit(0);
}
}
******************************************************
Making Multiple Comparisons in Decision Statements in Java Q Sear Making Multiple Airline java Comparisons in...
- Part 1 – 4 Debugging Exercises – there are things wrong – either logic or syntax errors. Correct the pseudocode and one Java program. Add the corrected code in BOLD and change the corrected color to RED. Debugging 4: Add the missing code in bold and red. import java.util.Scanner; public class Airline { public static void main(String args[]) { Scanner s = new Scanner(System.in); String passengerName = "" String ageString = "" int passengerAge = 0 System.out.println("Enter passenger's name: "); passengerName =...