CIST 1520 Chapter 3

Shipping and Handling Calculator:
Requirements
1. User Interface
1.1 Create a Web page that allows a user to enter a purchase price into a text box;
1.2 include a JavaScript function that calculates shipping and handling.
2. Processing
2.1 Add functionality to the script that adds a minimum shipping and handling fee of $1.50 for any purchase that is less than or equal to $25.00.
2.2 For orders over $25.00, add 10% to the total purchase price for shipping and handling, but do not include the $1.50 minimum shipping and handling fee.
2.3 The formula for calculating a percentage is price * percent / 100. EX: 10% of $50.00 purchase price = 50 * 10 / 100 = $5.00 .
3. Output/Format
3.1 After you determine the total cost of the order (purchase plus shipping and handling), display it in an alert dialog box.
3.2 Save the document as CalcShipping.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" dir="ltr">
<head>
	<title>Shipping and Handling Calculator</title>
	<script type="text/javascript">
/*![CDATA[ */

function calShipping(){
	var price = parseFloat(document.forms.shippingForm.price.value);
	var total=0;
	if(price <= 25){
		total = price + 1.50;
	}
	else{
		total = price+(price* (10/100));
	}
	alert("Your total price is: $"+ total.toFixed(2));
}
/* ]] */
</script>
</head>
<body>
	<h2>Shipping and Handling Fee Calculator</h2>
	<form id="shippingForm" name="shippingForm" method="post" onsubmit="return calShipping();">
		<strong>Please enter the price:</strong>
		<input type="text" id="price" name="price"/>
		<input type="submit" id="submit" name="submit" value=" SUBMIT "/>
	</form>
</body>
</html>

BMI Calculator:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" dir="ltr">
<head>
<title>BMI Calculator</title>
<script type="text/javascript">
/*![CDATA[ */
function calcBmi() {
	var weight = parseInt(document.forms.bmi.weight.value);
	var height = parseInt(document.forms.bmi.height.value);
	var BMI = parseInt((weight * 703) / (height * height));
	document.forms.bmi.result.value = BMI;
	return false;
}
/* ]] */
</script>
</head>
<body>
<h2>BMI Calculator</h2>
<form id="bmi" type="button" id="post" value="calculate" />
Weight (LBS): <input type="text" id="weight"/>
Height (IN): <input type="text" id="height"/><br/><br/>
BMI Result: <input type="text" id="result" /><br/><br/>
<input type="submit" id="submit" name="submit" value=" Calculate BMI " onclick="return calcBmi();"/>
</form>
</body>
</html>

EVEN NUMBERS

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Even Numbers</title>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
/* <![CDATA[ */
	var count = 1;
	while (count <= 100) {
		if (count % 2 == 0)
			document.write(count + "</br>");
		count++;
	}
/* ]]> */
</script>
</head>
<body>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *