<html>
<head>
<title>Assignment #10</title>
<body>
<h2>The Discount Store Calculator </h2>
<script language="JavaScript">
// INPUT section -- get information from the user
var normalprice = parseFloat( window.prompt("Enter the normal price of an item $" ) );
var numberofitem = parseFloat( window.prompt("Enter the number of items" ) );
// PROCESSING section -- perform calculations
if ( numberofitem >= 0 && numberofitem <= 9 ) {
document.write("<p>You want to purchase " + numberofitem);
document.write("<p>at the price is $ " + normalprice );
document.write("<p>The total cost is $ "+normalprice * numberofitem);
}
else if ( numberofitem >= 10 && numberofitem <= 99 ) {
document.write("<p>You want to purchase " + numberofitem);
document.write("<p>at the price is $ " + normalprice );
document.write("<p>For this purchase the discount rate is % 10 " );
document.write("<p>The amount saved is $ "+normalprice * numberofitem * .1);
document.write("<p>The total cost is $ "+normalprice * numberofitem * .9);
}
else if ( numberofitem >= 100 && numberofitem <= 499 ) {
document.write("<p>You want to purchase " + numberofitem);
document.write("<p>at the price is $ " + normalprice );
document.write("<p>For this purchase the discount rate is % 15 " );
document.write("<p>The amount saved is $ "+normalprice * numberofitem * .15);
document.write("<p>The total cost is $ "+normalprice * numberofitem * .85);
}
else if ( numberofitem >= 500 && numberofitem <= 1000 ) {
document.write("<p>You want to purchase " + numberofitem);
document.write("<p>at the price is $ " + normalprice );
document.write("<p>For this purchase the discount rate is % 20 " );
document.write("<p>The amount saved is $ "+normalprice * numberofitem * .20);
document.write("<p>The total cost is $ "+normalprice * numberofitem * .8);
}
else if ( numberofitem >= 1000 ) {
document.write("<p>You want to purchase " + numberofitem);
document.write("<p>at the price is $ " + normalprice );
document.write("<p>For this purchase the discount rate is % 25 " );
document.write("<p>The amount saved is $ "+normalprice * numberofitem * .25);
document.write("<p>The total cost is $ "+normalprice * numberofitem * .75);
}
else
{
document.write("Error");
}
</script>
</body>
</html>
Was able to do it and get it working first try..
.This post was edited by Buxx on Jun 13 2016 11:02pm