Question

In: Computer Science

Create a web page that contains a simple math test. The page should have the following...

Create a web page that contains a simple math test. The page should have the following arithmetic problems. Add a button under each problem which, when clicked, will display a prompt for the user to enter the answer. Add a swcond button which, when clicked, will check to see if the user's answer is correct. The output should be either "correct" or "incorrect" displayed in an alert box.

1. 5+9=

2. 4*6=

3. 25-14=

4. 48/3=

5. 26%6=

Solutions

Expert Solution

HTML CODE WITH JAVASCRIPT:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Index</title>
</head>
<body>
    <div id="prob1">
        <label id = "prob1-label">1. 5 + 9 = </label><br>
        <button id = "prob1-submit">Submit answer</button>
        <button id = "prob1-check">Check answer</button>
    </div>
    <div id="prob2">
        <label id = "prob2-label">2. 4 * 6 = </label><br>
        <button id = "prob2-submit">Submit answer</button>
        <button id = "prob2-check">Check answer</button>
    </div>
    <div id="prob3">
        <label id = "prob3-label">3. 25 - 14 = </label><br>
        <button id = "prob3-submit">Submit answer</button>
        <button id = "prob3-check">Check answer</button>
    </div>
    <div id="prob4">
        <label id = "prob4-label">4. 48 / 3 = </label><br>
        <button id = "prob4-submit">Submit answer</button>
        <button id = "prob4-check">Check answer</button>
    </div>
    <div id="prob5">
            <label id = "prob5-label">5. 26 % 6 = </label><br>
            <button id = "prob5-submit">Submit answer</button>
            <button id = "prob5-check">Check answer</button>
    </div>
    <script>
        var result1, result2, result3, result4, result5;
        document.getElementById("prob1-submit").addEventListener("click", function(){
            result1 = parseInt(prompt(document.getElementById('prob1-label').innerText));
        });
        document.getElementById("prob1-check").addEventListener("click", function(){
            if(5+9 == result1)
                alert("correct");
            else
                alert("incorrect");
        });
        document.getElementById("prob2-submit").addEventListener("click", function(){
            result2 = parseInt(prompt(document.getElementById('prob2-label').innerText));
        });
        document.getElementById("prob2-check").addEventListener("click", function(){
            if(4*6 == result2)
                alert("correct");
            else
                alert("incorrect");
        });
        document.getElementById("prob3-submit").addEventListener("click", function(){
            result3 = parseInt(prompt(document.getElementById('prob3-label').innerText));
        });
        document.getElementById("prob3-check").addEventListener("click", function(){
            if(25-14 == result3)
                alert("correct");
            else
                alert("incorrect");
        });
        document.getElementById("prob4-submit").addEventListener("click", function(){
            result4 = parseInt(prompt(document.getElementById('prob4-label').innerText));
        });
        document.getElementById("prob4-check").addEventListener("click", function(){
            if(48/3 == result4)
                alert("correct");
            else
                alert("incorrect");
        });
        document.getElementById("prob5-submit").addEventListener("click", function(){
            result5 = parseInt(prompt(document.getElementById('prob5-label').innerText));
        });
        document.getElementById("prob5-check").addEventListener("click", function(){
            if(26%6 == result5)
                alert("correct");
            else
                alert("incorrect");
        });
    </script>
</body>
</html>

SAMPLE OUTPUT:

FOR ANY HELP JUST DROP A COMMENT


Related Solutions

Create a Web page about yourself containing the following: Notepad++ The page should have a light...
Create a Web page about yourself containing the following: Notepad++ The page should have a light green background and a one inch margin. The Web page should contain: At least three headings, h1 to h3. At least two paragraphs about you. A numbered list with at least three hyperlinks. The hyperlinks cannot be the ones we created in class today which were the links to Yahoo and Google. Two horizontal rules. All the h1, h2, and h3 tags should have...
2 -​Create the code to generate a web page that contains a table. The table should...
2 -​Create the code to generate a web page that contains a table. The table should have 4 ​columns and 4 rows. Each cell should be 100 pixels wide by 100 pixels high. The border ​should be 2 ​pixels.
Create a simple web page with two(2) AJAX interactions with a mySQL Database AJAX 1 should...
Create a simple web page with two(2) AJAX interactions with a mySQL Database AJAX 1 should return HTML content for use on the page AJAX 2 should return JSON content for use on the page Use a JS library, such as jQuery, to ensure the AJAX works on all browsers
1 -​Create the code to generate a default web page. The contents of this page should...
1 -​Create the code to generate a default web page. The contents of this page should be Your​​Name, right justified
Create a web page using PHP and HTML that contains a list of movie names available...
Create a web page using PHP and HTML that contains a list of movie names available for rent (at least 10 movies), so that each time you visit the home page, you see a different order of movies in the list. The movie names are required. 2) The rental price for each movie ranges between $1.99 to $7.99. • Create an associative array with a code for the movie as the key (e.g., movie1, movie2, etc.) and the associated rental...
Using JavaScript, create a simple web page that will take orders for Chess Org. Chess Org...
Using JavaScript, create a simple web page that will take orders for Chess Org. Chess Org sells yearly membership for $30 each. Discounts are given for buying in bulk (see Table 1 and example below). Table 1 – Discounts Quantity Purchased Discount 1 – 29 0% 30 - 59 10% 60 + 15% Example: If a customer purchases 40 family membership, their total price (CTotal) would be: COriginalPrice = 30*40=1200 DMainDiscount = 1200*0.1=120 CTotalPrice = COriginalPrice - DMainDiscount= 1200-120 =...
Make a modest or simple Web page using Python flask. The basic components of HTML should...
Make a modest or simple Web page using Python flask. The basic components of HTML should be included. The Web page should have at least 3 Headings(<h1>), paragraph (<p>), comments (<!-- -->), ordered list, unordered list, three links to website, and should display time & date. Example: <html>     <head>         <title>Page Title</title>     </head> <body>     ..new page content.. </body> </html>
Create a Web Page Using HTML, CSS, JS, jQuery • Create a web profile, including any...
Create a Web Page Using HTML, CSS, JS, jQuery • Create a web profile, including any of the following: • Your hobbies, likes/dislikes, career aspirations, dream job, favorite animals/ pets, favorite superhero, etc. • You do not have to share personal information that you are uncomfortable with sharing. Follow these guidelines when creating your page: • Include at least one heading (h1, h2, etc.) in your web page. • Provide a quote from a book, movie, etc. • Include at...
Create a web page using PHP that allows the users to create an account (a username...
Create a web page using PHP that allows the users to create an account (a username and a password). There should be a login page that allows users to create an account by entering their preferred username and password. The same page should also let users login if they already have an account. If a user is logged in successfully , they should be able to enter a comment and also read the comments entered by others previously.
In one-page, create a memo on a policy that contains the following: Background of the issue...
In one-page, create a memo on a policy that contains the following: Background of the issue A discussion about other alternatives for the issue A financial analysis Evidence-based recommendations for action.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT