Question

In: Computer Science

A mail-order house sells five different products whose retail prices are as follows: product 1, $2.98;...

A mail-order house 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 script that reads a series of pairs of numbers as follows:

a) Product number

b) Quantity

sold for one day Your program should use a switch statement to determine each product’s retail price and should calculate and output HTML5 that displays the total retail value of all the products sold last week. Use a prompt dialog to obtain the product number and quantity from the user. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results.

HTML CODE PLZ

no need of database just need to use the given prices

Solutions

Expert Solution

ANSWER :

Code :-

<!DOCTYPE html>
<html lang="en">
<head> <!-- open of head -->

<meta charset="utf-8">
<title> Mail Order</title>
<link rel="shortcut icon" href="me.jpg">

</head>

<body> <!-- beginning of the body section -->

<header>

<h1>Mail Order </h1>

</header>

<script type="text/javascript">

function orderSummary() {
//hash for product costs
var productCost = {
//product1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49; and product 5, $6.87.
1 : 2.98,
2 : 4.50,
3 : 9.98,
4 : 4.49,
5 : 6.87
  
}
var productSelected = [];

var quantity = [];


var count = getOrders(productSelected, quantity);
  

var i = 0;
var total = 0;
var diff = 0;
var text = "<table cellspacing=\"3\"><tr><td>Product ID</td><td>Quantity</td><td>Cost</td><td></tr>" ;
var cost = 0;
for(i = 0; i <count; i++) {
cost = quantity[i] * productCost[productSelected[i]];
total += cost;
text += "<tr><td>"+productSelected[i]+"</td><td>"+quantity[i]+"</td><td>$"+cost+ "</td><td></tr>";
}
text += "<tr><td>Total Cost</td><td>&nbsp;</td><td>$"+total+"</td><td></tr></table>";
document.getElementById("content").innerHTML = text;
// alert(text);
}

function getOrders(productSelected, quantity) {
var i = 0;
var input = 0;
var loop = 1;
while(loop == 1) {
input = prompt("Enter Product Number: ");
if (input === null) {
loop =-1;
continue;
} else {
productSelected[i] = input;

input = prompt("Enter Quantity for Product#"+input+": ");
if (input === null) {
loop = 0;
continue;
}
quantity[i] = input;
i++;
}
}
return i;
}


</script>

<div id="content">
</div>
<script>
orderSummary();
</script>

</body>

</html>

Sample run :-

Hope it helps... please give an upvote. it's very important to me... thank you:?


Related Solutions

The logistics/operations manager of a mail order house purchases two products for resale: King Beds (K)...
The logistics/operations manager of a mail order house purchases two products for resale: King Beds (K) and Queen Beds (Q). Each King Bed costs $500 and requires 100 cubic feet of storage space, and each Queen Bed costs $300 and requires 90 cubic feet of storage space. The manager has $75,000 to invest in beds this week, and her warehouse has 18,000 cubic feet available for storage. Profit for each King Bed is $300, and for each Queen Bed is...
Lilliput, a one-product mail-order firm, buys its product for $55 per unit and sells it for...
Lilliput, a one-product mail-order firm, buys its product for $55 per unit and sells it for $153 per unit. The sales staff receives a 10% commission on the sale of each unit. Its December income statement follows.    LILLIPUT COMPANY Income Statement For The Month Ended December 31, 2011   Sales $ 1,530,000   Cost of goods sold 550,000      Gross profit 980,000   Expenses      Sales commissions (10%) 153,000      Advertising 246,000      Store rent 26,300        Administrative salaries 51,500      Depreciation 61,500      Other expenses 14,300   ...
Chastain Corporation produces three products, with costs and selling prices as follows: Product A Product B...
Chastain Corporation produces three products, with costs and selling prices as follows: Product A Product B Product C Selling price per unit $ 30 100 % $ 20 100 % $ 15 100 % Variable costs per unit 18 60 % 15 75 % 6 40 % Contribution margin per unit $ 12 40 % $ 5 25 % $ 9 60 % A particular machine is the bottleneck. On that machine, 3 machine hours are required to produce each...
Information regarding the selling prices and unit costs of three products is as follows: Product F...
Information regarding the selling prices and unit costs of three products is as follows: Product F G H Selling price $ 70 $ 50 $ 80 Variable costs $ 30 $ 20 $ 35 Fixed costs $ 10 $ 7 $ 7 Machine time (minutes) 10 5 5 Fixed costs are applied to the products on the basis of direct labor hours. Due to the amount of machine time available, the company cannot produce all the units demanded. The only...
A company sells two products. Information about two products is as follows: Product A: Sales Units-1200...
A company sells two products. Information about two products is as follows: Product A: Sales Units-1200 Selling price per unit-$20 variable costs per unit 11 Product B: Sales unit- 800 Selling price per unit- $25 Variable costs per unit- 18 If fixed costs are expected to be $12,300, what is the margin of safety?
Income is to be evaluated under four different situations as follows: a. Prices are rising: (1)...
Income is to be evaluated under four different situations as follows: a. Prices are rising: (1) Situation A: FIFO is used. (2) Situation B: LIFO is used. b. Prices are falling: (1) Situation C: FIFO is used. (2) Situation D: LIFO is used. The basic data common to all four situations are: sales, 502 units for $16,064; beginning inventory, 287 units; purchases, 388 units; ending inventory, 173 units; and operating expenses, $3,100. The income tax rate is 30%. Required: 1....
Income is to be evaluated under four different situations as follows: a. Prices are rising: (1)...
Income is to be evaluated under four different situations as follows: a. Prices are rising: (1) Situation A: FIFO is used. (2) Situation B: LIFO is used. b. Prices are falling: (1) Situation C: FIFO is used. (2) Situation D: LIFO is used. The basic data common to all four situations are: sales, 502 units for $16,064; beginning inventory, 287 units; purchases, 388 units; ending inventory, 173 units; and operating expenses, $3,100. The income tax rate is 30%. Required: 1....
Income is to be evaluated under four different situations as follows: a. Prices are rising: (1)...
Income is to be evaluated under four different situations as follows: a. Prices are rising: (1) Situation A: FIFO is used. (2) Situation B: LIFO is used. b. Prices are falling: (1) Situation C: FIFO is used. (2) Situation D: LIFO is used. The basic data common to all four situations are: sales, 517 units for $18,612; beginning inventory, 295 units; purchases, 386 units; ending inventory, 164 units; and operating expenses, $4,000. The income tax rate is 30%. Required: 1....
Qubix Systems produces two different products, Product A, which sells for $250 per unit, and Product...
Qubix Systems produces two different products, Product A, which sells for $250 per unit, and Product B, which sells for $400 per unit, using three different activities: Design, which uses Engineering Hours as an activity driver; Machining, which uses machine hours as an activity driver; and Inspection, which uses number of batches as an activity driver. The cost of each activity and usage of the activity drivers are as follows: Cost Usage by Product A Usage by Product B Design...
Walnut Systems produces two different products, Product A, which sells for $123 per unit, and Product...
Walnut Systems produces two different products, Product A, which sells for $123 per unit, and Product B, which sells for $205 per unit, using three different activities: Design, which uses Engineering Hours as an activity driver; Machining, which uses machine hours as an activity driver; and Inspection, which uses number of batches as an activity driver. The cost of each activity and usage of the activity drivers are as follows:     Cost Usage by Product A Usage by Product B Design...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT