Ask Question
26 March, 02:25

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 March, 03:59
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers