Sample Exam Question: Museum Admission

On your final exam, you can expect to be asked a question VERY similar to the one shown here. The scenario will be different, but the types of things you will be asked to do in your JavaScript will be extremely similar. (i.e. Determine if a checkbox or radio button was checked, retrieve a value from a checkbox or radio button). And of course, you should always be prepared to

On your exam, you will be provided with some HTML code (along with an image to show you what the page will look like), and you will be required to write the JavaScript function that make it work.

NOTES:

Below is what the exam question might look like.


 

The Exam Question

Look at the page shown here:

museum_admission.png

Below is the relevant HTML code that was used to generate this page.

Write a JavaScript function that will calculate the cost of admission to the museum.

  1. Retrieve the initial cost by determining which type of exhibit the visitor wishes to view.

  2. If they are a senior citizen, deduct $5

  3. If they are a member of the museum, deduct 10% off their cost.

Output the amount of the tip to the div section called 'output'.

For example:

 

museum_admission.png

In this example, the user has indicated that they wanted to see the special exhibit which makes their initial cost $15. They then indicated that they are a senior citizen, so the cost should be reduced by $5 to make it $10. They then indicate that they are a member of the museum, so the cost should be reduced by 10% (i.e. multiply the cost by 0.9) to leave the end cost as $9.

You must use concatenation. So your ‘output’ section should say something like: Your entry fee is $9.

Note that there is a $ before the cost, and a period at the end of the sentence. This should be present in the output.