Popcorn Sales Form, Exams of Computer Science

A web page for a popcorn sales form. The page includes a form with input fields for the buyer's name, address, and the quantities of different types of popcorn they would like to order. The form also includes radio buttons for the payment method. The xhtml code for the web page, as well as css and javascript functions to style the page and validate the input. This document could be useful for students studying web development, e-commerce, or form design, as it covers topics such as html form elements, css styling, and javascript validation.

Typology: Exams

2023/2024

Available from 08/04/2024

solution-master
solution-master 🇺🇸

3.3

(28)

11K documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
SOEN 287 MIDTERM EXAM
(Department of Computer
Science Web Programming)
CONCORDIA UNIVERSITY
IDENTIFICATION:
First Name ______________
Last Name_______________
ID ________________
Signature
Information:
1.
This is a close book exam.
2.
Please answer all questions 100 points as shown.
3.
Please put your answer to the multiple choice questions in the table below.
Questions
Mark
Section I
Answer
1
/5
2
/5
3
/5
4
/5
5
/5
6
/5
7
/5
8
/5
9
/5
10
/5
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Popcorn Sales Form and more Exams Computer Science in PDF only on Docsity!

SOEN 287 MIDTERM EXAM

(Department of Computer

Science Web Programming)

CONCORDIA UNIVERSITY

IDENTIFICATION:

First Name ______________ Last Name_______________ ID ________________

Signature

Information:

**1. This is a close book exam.

  1. Please answer all questions – 100 points as shown.
  2. Please put your answer to the multiple choice questions in the table below.**

Questions Mark

Section I Answer

Section II

Section III

Total /

//below is a JavaScript statement ‘$’ + (4+5)

B. h1.all {background-color:#FFFFFF} C. h1 {background-color:#FFFFFF} D.. h1 {background-color:#FFFFFF} Answer: C

  1. In which color will the level 2 heading be displayed after applying thestyle defined in the box at right? A. Blue B. Green C. Red D. Black Answer: D
  2. Which of the following choice is valid XHTML code? A.

    This is a paragraph

    B.

    This is a paragraph

    C.

    This is a paragraph D.

    This is nested

    Answer: A
  3. Write the result of a JavaScript express the the box blow:

A. $

B. $

C. NaN D. undefined E. error Answer: A

**

This is level 2 heading. **

  1. What is the final value of variable sum after the following JavaScript code is executed? A. 20 B. 0 C. 1 D. 21 E. none of the above

Answer: C

Section II: Short Answer Questions (20 points)

  1. Write the answers to the JavaScript function call. (10 points)

A. test(“2”, “3”,”4”) returns ____________ B. test(2, 3, 4) returns C. test(“2”, 3, ”4”) returns

D. test(3, “a”, 4) returns ______

E. test(false, true, false) returns

answer:

A. test(“2”, “3”,”4”) returns ____false________ B. test(2, 3, 4) returns true C. test(“2”, 3, ”4”) returns false D. test(3, “a”, 4) returns false

E. test(false, true, false) returns true

  1. Fill the blank lines with the color used to show the strings on a browser. For example, if theline is showed in blue, fill the line with “blue” (10 points).

test(a, b, c){ return a + bc == bc+a; }**

var sum = 0; function add_t() { var sum = sum + 20; }

add_t(); sum = sum + 1;

Section III: Answer the Following Questions with Code (30 points)

The box at the right shows a Web page to receive the orders for popcorn.

  1. (10 points) Finish the XHTML document for this Web page.

< > Popcorn Sales Form </ >

< > Welcome to Millenium GynmasticsBooster Club Popcorn Sales

type = " " name =

Street Address: <

type = " " name = "street" size = "30" />

City, State, Zip: <

type = " " name = "city" size = "30" />

Product Name Price Quantity

Unpopped Popcorn (1 lb.) $3.00 <

type = " " name = "unpop" size ="2" />

Caramel Popcorn (2 lb. cannister) $3.50 <

type = " " name = "caramel" size = "2" />

Caramel Nut Popcorn (2 lb. cannister) $4.50 <

type = " " name = "caramelnut" size = "2" />

Toffey Nut Popcorn (2 lb. cannister) $5.00 <

type = " " name = "toffeynut" size = "2" />

Payment Method:

< type = " " name = "payment"


value = "visa" checked = "checked" /> Visa

< type = " " name = " "


value = "mc" /> Master Card

< type = " " name = " "


value = "discover" /> Discover

< type = " " name = "payment" value = "check" /> Check


< <

</ >

Answer:

type = " " value = "Submit Order" /> type = " " value = "Clear Order Form" />

Caramel Popcorn (2 lb. cannister) $3.50

Caramel Nut Popcorn (2 lb. cannister) $4.50

Toffey Nut Popcorn (2 lb. cannister) $5.00

Payment Method:

Visa


Master Card


Discover


Check


  1. (10 points) Please write css code to change the display. You need to use proper selectors and NOT use

inline style.

a) Change the background color of the whole page to green.

Answer: body {background-color: green}

b) All the headings (H1-H6) of this page should be displayed in italic, bold, and Arial font.

Answer:

h1, h2, h3, h4, h5, h6 {font-style: italic; font-family: Arial; font-weight: bold}

c) Style the table to take 50% of the browser window.

Answer: #order {width: 50%};

  1. (10 points) Please finish the following two JavaScript functions for the functionality described below.

You do not need to program how the two functions are called.

  1. function paymentChoice (value): the value is obtained from the query string “payment”. You need to pop up a window to show one of the following strings according to the selection: “you have chosen Visa”, “you have chosen Master Card”, “you have chosen Discovery Card”, “you have chosen Check.
  2. function validate(quantity): the quantity should be a positive number. Please use this function to validate it. You should use regular expression to do it.

Answer:

// popcorn_validatorr.js

// Produce an alert message about the chosen payment

function paymentChoice (value) {

switch (value) { case "visa": alert("you have chosen Visa"); break; case "mc": alert("you have chosen Master Card"); break; case "discover": alert("you have chosen Discovery Card "); break; case "check": alert("you have chosen Check"); break;