Answer to Question #255642 in Java | JSP | JSF for Grace

Question #255642
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-23T23:31:15-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(C - citizen, N - non-citizen): ");
        String citizen = in.next();
        System.out.print("Recommendee(R - recommendee, N - non-recommendee): ");
        String recommended = in.next();
        if (recommended.equalsIgnoreCase("R") ||
                (height >= 200 && age >= 21 && age <= 25 && citizen.equalsIgnoreCase("C"))) {
            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