Skip to content

Instantly share code, notes, and snippets.

@Drarok
Created May 5, 2009 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drarok/107074 to your computer and use it in GitHub Desktop.
Save Drarok/107074 to your computer and use it in GitHub Desktop.
<HTML>
<HEAD>
<TITLE>Volume Discount</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
// A program to tell a customer what volume discount they can expect.
var numberOfGiftBoxes = window.prompt('Please enter now many boxes you are purchasing.', '');
var boxes = parseFloat(numberOfGiftBoxes);
if (isNaN(boxes))
{
alert('Invalid value for boxes. Please enter a number.')
}
else
{
var discount;
if (boxes <= 3)
{
discount = 'No Discount';
}
else if (numberOfGiftBoxes <= 11)
{
discount = '5% Bulk Purchase Discount';
}
else if (numberOfGiftBoxes <= 30)
{
discount = '10% Bulk Purchase Discount';
}
else
{
discount = '20% Bulk Purchase Discount';
}
document.write(discount);
}
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment