Question

In: Computer Science

~ JavaScript Only ~ Suppose you want to create selection menu for a comic book library...

~ JavaScript Only ~

Suppose you want to create selection menu for a comic book library that looks like the following:

-----------Comic Library Menu----------
(L)oad Library
(S)earch Library
(A)nalyze Library
(P)rint Library
(Q)uit

The menu is displayed and THEN a WHILE LOOP is entered to display the following command prompt: "Please enter a command (press (m) for menu): "

A scanner reads the user selection. Menu commands should be case insensitive ('L' and 'l' both load the library). A SWITCH STATEMENT is then used to process the menu selection. If user selects 'm,' the menu should be printed again. If an invalid command is entered, display invalid selection message and display the command prompt once again. If the user selects 'q', the selection loop should exit and display a goodbye message.

Please provide a solution. Thank you.

Solutions

Expert Solution

<!DOCTYPE html>

<html>

<body>

<p id="demo"></p>

<script>

    var menu = "-----------Comic Library Menu----------<br> (L)oad Library<br>(S)earch Library<br>(A)nalyze Library<br>(P)rint Library<br>(Q)uit"

    document.getElementById("demo").innerHTML = menu ;

        

        ch='y';

        while(ch=='y')

        {

            var x = prompt("Please enter a command (press (m) for menu):");

            switch (x) {

            case 'm':

            case 'M':

                    document.getElementById("demo").innerHTML = menu ;

                     break;

             case 'l':

             case 'L':

                   alert("Load Library");

                   break;

            case 's':

            case 'S':

                    alert("Search Library");

                 break;

            case 'a':

            case 'A':

                    alert("Analyze Library");

                 break;

            case 'p':

            case 'P':

                    alert("Print Library");

                 break;

            case 'Q':

            case 'q':

                    alert("Exiting");

                    ch='n'

                 break;

            default: window.alert("Invalid Selection");

        }

    }

</script>

</body>

</html>



Related Solutions

You must prompt the user to enter a menu selection. The menu will have the following...
You must prompt the user to enter a menu selection. The menu will have the following selections (NOTE: all menu selections by the user should not be case sensitive): 1. ‘L’ – Length a. Assume that a file containing a series of names is called names.txt and exists on the computer’s disk. Read that file and display the length of each name in the file to the screen. Each name’s middle character or characters should be displayed on a line...
Create a menu in Java. A menu is a presentation of options for you to select....
Create a menu in Java. A menu is a presentation of options for you to select. You can do this in the main() method. 1. Create a String variable named menuChoice. 2. Display 3 options for your program. I recommend using 3 System.out.println statements and a 4th System.out.print to show "Enter your Selection:". This needs to be inside the do -- while loop. A. Buy Stock. B. Sell Stock X. Exit Enter your Selection: 3. Prompt for the value menuChoice....
Class, Let's create a menu in Java. A menu is a presentation of options for you...
Class, Let's create a menu in Java. A menu is a presentation of options for you to select. You can do this in the main() method. 1. Create a String variable named menuChoice. 2. Display 3 options for your program. I recommend using 3 System.out.println statements and a 4th System.out.print to show "Enter your Selection:". This needs to be inside the do -- while loop. A. Deposit Cash. B. Withdraw Cash X. Exit Enter your Selection: 3. Prompt for the...
Python we need to create a game using only the library graphic.py and use only Structure...
Python we need to create a game using only the library graphic.py and use only Structure Functions only.
Please write in C++ as simple as possible I want you to create a Book Class...
Please write in C++ as simple as possible I want you to create a Book Class for a bookstore. I am not going to tell you what variables should go into it, that is for you to figure out (but you should have at least 5+). And then you must create a UML with all the variables and methods (like: the getters and setters, a default constructor, and a constructor that takes all the variables and finally the printValues() )....
Using HTML/Javascript (if needed) I want to create a table for a website that pulls data...
Using HTML/Javascript (if needed) I want to create a table for a website that pulls data from another website where the data is being updated on. Example: https://investors.coca-colacompany.com/stock-information/historical-data I cannot just put in the numbers to a table as they will be getting updated daily. So it needs to link the the website elements. DATE OPEN HIGH LOW CLOSE VWAP VOLUME % CHG CHANGE TRADE VAL TOTAL TRADES 2020-10-13 -- -- -- 51.09 -- -- 0.00% -- -- -- 2020-10-12...
Suppose you want to buy Amazon stock if and only if you can buy it for...
Suppose you want to buy Amazon stock if and only if you can buy it for less than $3100/share. The kind of order you should place today if it is trading at $3164/share is a: Select one: a. Limit order b. Market order c. Stop-loss order d. Fungible order
Suppose you want to know the variance of the weights of the only five iguanas in...
Suppose you want to know the variance of the weights of the only five iguanas in a particular zoo. You measure their weights to be 8.3, 8.4, 8.6, 9.2, and 9.5 pounds (15 points) What was different between the population variance and the sample variance? Which is bigger? Why is there a need to have a different formula? Write at least five good sentences in answering this question. (3 points) The population standard deviation is the square root of the...
please create a tic tac toe game with python using only graphics.py library
please create a tic tac toe game with python using only graphics.py library
Create a web calculator with JavaScript. Only four operations (Add, Sub, Multiplication, and Division) Use a...
Create a web calculator with JavaScript. Only four operations (Add, Sub, Multiplication, and Division) Use a CE button to cancel the operation.    Use the following website or any online resource as a reference. Don’t use their CSS or any other code.                 https://freshman.tech/calculator/ I am trying to learn please make comments then I will understand better.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT