(iii) An imaginary internet clothing store operates the following delivery
charges.
For orders worth less than £25 the delivery charge is £3.00.
Orders worth at least £25 but less than £100 are delivered free.
Orders worth £100 or more are delivered free and in addition the
customer receives a free gift.
We have started writing a JavaScript program that prompts a user to
enter the value of their order, then tells them which of the categories
above will apply.
// A delivery charge program
var orderValue; // How much the order is worth
orderValue = window.prompt('How much is the order worth in
Pounds Sterling?','');
document.write('The value of your order is £' + orderValue
+ '.
');
// Insert your code here
document.write('
');
document.write('Thank you for shopping with us.');
Figure 7 An incomplete JavaScript program
(a) Using program_7.3.9 as a guide, complete the code above so that
it will work out which band the order falls in, then display a
suitable message on the screen using the document.write()
method. Please note the following points.
1 You will need to add appropriate HTML tags before and after
the code, as well as completing the JavaScript where
indicated. program_7.3.9 will show you what HTML tags to
use. You should give the window the title 'Delivery charges'.
2 There is no need for your program to check that the user's
input is actually a valid number; you may assume that this will
always be the case.
3 You should use indentation to help make the structure of your
program clear, in the same way program_7.3.9 does.
page 12 of 12
4 A copy of the incomplete program as shown above in Figure 7
can be found in the file Q4(iii).html that you downloaded
with this assignment.
Insert a copy of your completed program into the document
containing your solution. [8]
(b) Run your program with each of the following inputs. (Note that
you only need to enter the figures, without any £ sign.)
24
25
99
100
For each run insert a screen shot of the browser window into the
document containing your solution.