Ask Question
26 February, 15:23

Write an if-else statement that checks patronAge. If 55 or greater, print "Senior citizen", otherwise print "Not senior citizen" (without quotes). End with newline.

+1
Answers (1)
  1. 26 February, 17:16
    0
    if (patronAge>=55) {

    System. out. println ("Senior Citizen");

    }

    else{

    System. out. println ("Not Senior Citizen");

    }

    Explanation:

    Using if and else statements, the condition is checked.

    The if statement will evaluate to true if the patronAge is greater or equal to 55 and the statement System. out. println ("Senior Citizen"); will be executed.

    If this this condition is not true, the else part System. out. println ("Not Senior Citizen"); will be executed

    A complete Java code snippet is given below that prompts user to enter an age and prints the corresponding message

    import java. util. Scanner;

    public class num6 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter Patron Age");

    int patronAge = in. nextInt ();

    if (patronAge>=55) {

    System. out. println ("Senior Citizen");

    }

    else{

    System. out. println ("Not Senior Citizen");

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write an if-else statement that checks patronAge. If 55 or greater, print "Senior citizen", otherwise print "Not senior citizen" (without ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers