Ask Question

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.

+5
Answers (1)
  1. 12 September, 10:00
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers