Develop an algorithm and write the JavaScript that creates a web page that enabl
ID: 3543739 • Letter: D
Question
Develop an algorithm and write the JavaScript that creates a web page that enables the user
to order campaign buttons. Your code will:
Display the name of the company (you make this up) and the price of campaign pins
(10 or less $0.50 each; 11 - 30 $0.45 each; 30 - 60 $0.40 each; and over 60 only $0.25 each)
display a prompt box and asks the customer to enter their name
display another prompt box for the amount of camapign pins the customer wants to order
(this will be an integer)
display a third prompt box for the state the pins are to be delivered.
your code will apply the following shipping charges based on the price of the total order.
$5.00 - $8.00 will have a $1.00 shipping charge; $8.01 - $10.00 will have a $1.50 shipping
charge; and over 10.00 will have a $2.00 shipping charge.
So if a customer bought 100 campaign pins at $0.25 each the total cost for that customer is
: 100*.25 = $25.00 + 2.00 in shippipng for a grand total of $27.00
Display in the web page the customer's name, the amount of buttons purchased
, the total cost of the buttons, the total cost including shipping, and the state to which the buttons are to be shipped .
I have to write this in notepad and save it as html,Also i need it basic java format no advanced codes please!
IT SHOULD BE THIS TYPE OF FORMAT..
Explanation / Answer
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>XYZ Company</title>
</head>
<body>
<script type="text/javascript">
var custoname;
var custoEmail;
var numButtons;
var ITEM_PRICE;
var SHIPPING_FEE=0;
var buttonPriceTotal;
var orderTotal;
var custoState;
var BR = "<br />";
var PA = "<p />";
var ES = "";
document.write("Welcome to BuzzButtons: It starts the Buzz!" + BR);
custoname = prompt("What name would you like on your buttons?", ES);
custoEmail = prompt("What is your email address?", ES);
custoState = prompt("What is your state?", ES);
numButtons = prompt("How many buttons would you like?", ES);
numButtons = parseInt(numButtons);
if (numButtons <= 10) ITEM_PRICE = 0.5;
if (numButtons > 10 && numButtons <= 30) ITEM_PRICE = 0.45;
if (numButtons >= 30 && numButtons <= 60) ITEM_PRICE = 0.4;
if (numButtons > 60) ITEM_PRICE = 0.25;
buttonPriceTotal = numButtons * ITEM_PRICE;
if (buttonPriceTotal >= 5 && buttonPriceTotal <= 8) SHIPPING_FEE = 1;
if (buttonPriceTotal >= 8.01 && buttonPriceTotal <= 10) SHIPPING_FEE = 1.5;
if (buttonPriceTotal > 10) SHIPPING_FEE = 2;
orderTotal = buttonPriceTotal + SHIPPING_FEE;
var str = "Your Name: " + custoname + "<br />" +
"Number of buttons ordered: " + numButtons + "<br />" +
"Total for buttons: " + buttonPriceTotal + "<br />" +
"Total amount of order: " + orderTotal + "<br />" +
"State to which it will be shipped: "+ custoState+ "<br />" +"<br />" +
"Thank you! we will email you the shipping information shortly.";
document.write(str);
</script>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.