Internet Programming and Applications - Test

CP 221: Internet Programming and Applications I
TEST ONE (20 Marks)
11th May 2022
Time: 60 Minutes


QUESTION ONE

Write a simple HTML5 page with the title “Simple CSS example”. The body of the page should contain a single paragraph with the text “Hello”. The text should have the “color” property set to “green”. An internal style sheet should be used to define an appropriate style that can be applied to the paragraph.
(3 Marks)


QUESTION TWO

Write a program that does basic arithmetic. Display a form with text box inputs for two operands and a <select> menu to choose an operation: addition, subtraction, multiplication, or division. Use a JavaScript function to validate the inputs to make sure that they are numeric and appropriate for the chosen operation. The processing function should display the operands, operator, and the result. For example, if the operands are 4 and 2 and the operation is multiplication, the processing function should display something like “4 * 2 = 8”.
(7 Marks)


QUESTION THREE

Dodoma Shoppers Parking System charges a 500 Tsh. minimum fee to park for up to three hours. The Parking charges an additional 200 Tsh. Per hour in excess of three hours. The maximum charges for any given 24-hour period is 2000 Tsh. Assume that no car parks for longer than 24 hours at a time. Write a script that calculates and display the parking charges for each customer who parked a car in this parking yesterday. You should input from the user the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the running total of yesterday’s receipts. The program should use the Javascript function calculateCharges to determine the charge for each customer. Use a text input field to obtain the input from the user. Use a JavaScript to validate the inputs to make sure that they are valid.
(10 Marks)


END OF TEST