TMA M150 03 Cut-off date: 26 March 2009
Question 1 [25 marks]
For each part of the question where you are asked to write or amend code you must copy the JavaScript code into your solution document in the appropriate place for that question and include a correctly named HTML file in the zip archive.
The home shopping company ArabShop is moving from its long established telephone shopping business to an internet-based system. The system will have two kinds of users: shoppers, who will order goods and services from the company; and administrators, whose task is to manage the secure internal parts of the system, such as stock lists, credit card numbers and prices. In this question you will concentrate on shoppers.
An established customer of ArabShop logs in to their account with a password. New customers must first register with the systems to set up their account and password.
(i) Make a copy of the file M150_TMA03_2007J_Q1.html, which we have supplied as a template for this question, and rename it M150_TMA03_2007J_Q1(i).html. Using this template, write a JavaScript program that prompts the user to enter 1 if they want to register as a new customer; and 2 if they are an established customer. If the user inputs anything other than 1 or 2, the system prompts them to try again. Do not use a loop: if the input is still not valid after two tries, the program does not produce any output.
Once a user has successfully entered 1 or 2, your system should print a welcome message. New customers should get the message “WELCOME – WE WILL SET UP YOUR ACCOUNT DETAILS NOW”; established customers will just get the message “SHOP UNTIL YOU DROP”.
Insert a copy of your JavaScript code into your solution document. [5]
(ii) Make a copy of the file M150_TMA03_2007J_Q1(i).html and rename it M150_TMA03_2007J_Q1(ii).html.
Amend this file to include code for the entry of customer details. Individuals starting a new account must enter the following data: first name, last name and a password of their own choice.
Passwords must be at least 7, and no more than 15, characters long. If users enter a password that is invalid according to this rule then the program displays an explanatory message, telling the user how many characters the password entered actually had, and prompts them repeatedly until a valid password is entered.
Test your program with the name Tim Horton and passwords coffee, NorthAmCa12.
Insert a copy of your JavaScript code into your solution document followed by a screenshot of the browser window showing the result of your test with the password Kane12. [9]
(iii) Make a copy of the file M150_TMA03_2007J_Q1(ii).html and rename it M150_TMA03_2007J_Q1(iii).html.
Amend this file so that your program allocates the new customer a customer code. The customer code is a string made up of the first letter of the first name, plus the first letter of the last name, and a dash. Thus, a customer with the following details:
First name: Tim
Second name: Horton Password: NorthAmCa12
Will have the customer code: TH-
Your program should write the first name, the last name and the customer code to the screen. Test your program on the data given above.
Insert a copy of your JavaScript code into your solution document followed by a screenshot of the browser window showing the result of your test. [4]
(iv) Make a copy of the file M150_TMA03_2007J_Q1(iii).html and rename it M150_TMA03_2007J_Q1(iv).html.
Amend this file so that your program displays what the customer has just entered. Add code that writes out a welcome message, followed by the customer’s first name, last name and password: the password should only display the first and last characters; otherwise asterisks should replace the actual characters.
Test your program on the inputs you used in part (iii) above. The output from your program should resemble Figure 1 on the following page.
Figure 1 Example of a welcome message followed by customer details
Insert a copy of your JavaScript code into your solution document followed by a screenshot of the browser window showing the result of your test. [7]
Question 1 [25 marks]
For each part of the question where you are asked to write or amend code you must copy the JavaScript code into your solution document in the appropriate place for that question and include a correctly named HTML file in the zip archive.
The home shopping company ArabShop is moving from its long established telephone shopping business to an internet-based system. The system will have two kinds of users: shoppers, who will order goods and services from the company; and administrators, whose task is to manage the secure internal parts of the system, such as stock lists, credit card numbers and prices. In this question you will concentrate on shoppers.
An established customer of ArabShop logs in to their account with a password. New customers must first register with the systems to set up their account and password.
(i) Make a copy of the file M150_TMA03_2007J_Q1.html, which we have supplied as a template for this question, and rename it M150_TMA03_2007J_Q1(i).html. Using this template, write a JavaScript program that prompts the user to enter 1 if they want to register as a new customer; and 2 if they are an established customer. If the user inputs anything other than 1 or 2, the system prompts them to try again. Do not use a loop: if the input is still not valid after two tries, the program does not produce any output.
Once a user has successfully entered 1 or 2, your system should print a welcome message. New customers should get the message “WELCOME – WE WILL SET UP YOUR ACCOUNT DETAILS NOW”; established customers will just get the message “SHOP UNTIL YOU DROP”.
Insert a copy of your JavaScript code into your solution document. [5]
(ii) Make a copy of the file M150_TMA03_2007J_Q1(i).html and rename it M150_TMA03_2007J_Q1(ii).html.
Amend this file to include code for the entry of customer details. Individuals starting a new account must enter the following data: first name, last name and a password of their own choice.
Passwords must be at least 7, and no more than 15, characters long. If users enter a password that is invalid according to this rule then the program displays an explanatory message, telling the user how many characters the password entered actually had, and prompts them repeatedly until a valid password is entered.
Test your program with the name Tim Horton and passwords coffee, NorthAmCa12.
Insert a copy of your JavaScript code into your solution document followed by a screenshot of the browser window showing the result of your test with the password Kane12. [9]
(iii) Make a copy of the file M150_TMA03_2007J_Q1(ii).html and rename it M150_TMA03_2007J_Q1(iii).html.
Amend this file so that your program allocates the new customer a customer code. The customer code is a string made up of the first letter of the first name, plus the first letter of the last name, and a dash. Thus, a customer with the following details:
First name: Tim
Second name: Horton Password: NorthAmCa12
Will have the customer code: TH-
Your program should write the first name, the last name and the customer code to the screen. Test your program on the data given above.
Insert a copy of your JavaScript code into your solution document followed by a screenshot of the browser window showing the result of your test. [4]
(iv) Make a copy of the file M150_TMA03_2007J_Q1(iii).html and rename it M150_TMA03_2007J_Q1(iv).html.
Amend this file so that your program displays what the customer has just entered. Add code that writes out a welcome message, followed by the customer’s first name, last name and password: the password should only display the first and last characters; otherwise asterisks should replace the actual characters.
Test your program on the inputs you used in part (iii) above. The output from your program should resemble Figure 1 on the following page.
Figure 1 Example of a welcome message followed by customer details
Insert a copy of your JavaScript code into your solution document followed by a screenshot of the browser window showing the result of your test. [7]