Question

A company sells five different products whose retail prices are as follows: product 1, $2.98; product...

A company sells five different products whose retail prices are as follows: product 1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49; and product 5, $6.87. Write a JavaScript code for the below:

  1. Product number
  2. Quantity sold for the day

Make use of a prompt dialog to obtain the product number, quantity and price from the user. Displays the total price of all the products.

Homework Answers

Answer #1

Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script type = "text/javascript">
            function getVal() {
               var prodVal = prompt("Enter product number : ", "");
               var quanVal = prompt("Enter the quantity : ", "");
               var priceVal = prompt("Enter price : ", "");
               var total = quanVal*priceVal
               document.getElementById("area").innerHTML = ("Product number is : " + prodVal + "<br>Quantity is : " + quanVal + "<br>Price is : " + priceVal + "<br>The total price of all products is: " + total);
            }
    </script>
</head>
<body>
     <table>
        <th>Product number</th>
        <th>Product price</th>
        
        <tr>
            <td>Product 1</td>
            <td>$2.98</td>
        </tr>
        <tr>
            <td>Product 2</td>
            <td>$4.50</td>
        </tr>
        <tr>
            <td>Product 3</td>
            <td>$9.98</td>
        </tr>
        <tr>
            <td>Product 4</td>
            <td>$4.49</td>
        </tr>
        <tr>
            <td>Product 5</td>
            <td>$6.87</td>
        </tr>
     </table>  
        
     <br>    
         
     <form>
         <input type = "button" value = "Click to input" onclick = "getVal();" />
     </form>
      
      <div id="area">
      </div>
</body>
</html>

Code screenshot:

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(Calculating Sales) An online retailer sells five products whose retail prices are as follows: Product 1,...
(Calculating Sales) An online retailer sells five products whose retail prices are as follows: Product 1, $$2.98; Product 2, $4.50; Product 3, $9.98; Product 4, $4.49, and Product 5, $6.87. Write an application that reads a series of pairs of numbers s follows: a) product number b) quanity sold Your program should use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. Use a sentinel-controlled...
Forester Company has five products in its inventory. Information about the December 31, 2021, inventory follows....
Forester Company has five products in its inventory. Information about the December 31, 2021, inventory follows. Product Quantity Unit Cost Unit Replacement Cost Unit Selling Price A 700 $ 21 $ 23 $ 27 B 1,000 26 22 29 C 900 14 13 19 D 600 18 15 17 E 500 25 23 24 The cost to sell for each product consists of a 20 percent sales commission. The normal profit for each product is 40 percent of the selling...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT