Ask Question
10 March, 00:15

Display list of numbered or lettered choices for actions

• Prompt user to make selection

• Test user selection in expression

If a match, then execute code for action - if not, then go on to next expression

+5
Answers (1)
  1. 10 March, 04:01
    0
    import java. util. Scanner;

    public class num1 {

    public static void main (String[] args) {

    System. out. println ("Age Greater than 18?");

    System. out. println ("Y = / "Yes/"/t N = / "No/"");

    Scanner in = new Scanner (System. in);

    char response = in. next (). charAt (0);

    switch (response) {

    case 'Y':

    case 'y':

    System. out. println ("You can Visit this Website");

    break;

    case 'N':

    case 'n':

    System. out. println ("You are to young to visit this website");

    break;

    default:

    System. out. println ("You response is not valid");

    }

    }

    }

    Explanation:

    Using Java programming language create a list of options for users to input "yes" or "no" Using the imported scanner class, prompt, receive and store the user's response in a char variable. Use the switch statement in an expression to test user input and print appropriate message. If there is no match print the default message
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Display list of numbered or lettered choices for actions • Prompt user to make selection • Test user selection in expression If a match, ...” 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