An applicant will accepted to the Jedi Knight Military Academy if he is least 200 cm. tall; age is between 21 and 25, inclusive; and a citizen of the Planet Endor. However, if the applicant is a recommendee of Jedi Master Obi Wan, he is accepted automatically regardless of his height, age and citizenship. Write a program that would input the applicant’s height, age, citizenship code(“C” for citizen of Endor, “N” for non-citizen), and recommendee code (“R” for recommendee, “N” for non-recommendee) and then output whether the applicant is accepted or rejected.
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter height: ");
int height = keyBoard.nextInt();
System.out.print("Enter age: ");
int age = keyBoard.nextInt();
System.out.print("Enter citizenship code('C' for citizen of Endor, 'N' for non-citizen: ");
String citizen = keyBoard.next();
System.out.print("Enter recommendee code ('R' for recommendee, 'N' for non-recommendee): ");
String recommended = keyBoard.next();
if (recommended.equalsIgnoreCase("r")
|| (height >= 200 && age >= 21 && age <= 25 && citizen.equalsIgnoreCase("c"))) {
System.out.println("Accepted");
} else {
System.out.println("Rejected");
}
keyBoard.close();
}
}