Answer to Question #254177 in Java | JSP | JSF for Yanyan

Question #254177
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-20T23:55:26-0400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Height: ");
        int height = in.nextInt();
        System.out.print("Age: ");
        int age = in.nextInt();
        System.out.print("Citizen(Y/N): ");
        String citizen = in.next();
        System.out.print("Recommended(Y/N): ");
        String recommended = in.next();
        if (recommended.equalsIgnoreCase("y") ||
                (height >= 200 && age >= 21 && age <= 25 && citizen.equalsIgnoreCase("y"))) {
            System.out.println("Accepted");
        }else{
            System.out.println("Rejected");
        }

    }
}

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