Answer to Question #254998 in Java | JSP | JSF for mikay

Question #254998
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.
1
Expert's answer
2021-10-22T06:50:46-0400


import java.util.Scanner;


public class App {
	/**
	 * The start point of the program
	 * 
	 * @param args
	 */
	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();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS