Lab 1 Concert Ticket Calculator

Similar documents
Lab 2 Population. Purpose. Assignment Lab 2 analyzes population growth of a town as well as compare the population growth of two towns.

Lab 1. Purpose. Assignment. Action Items/Programming Requirements

Lab 3 - Pizza. Purpose. Assignment

ITEC136 - Lab 2 Population

c122mar413.notebook March 06, 2013

Assessment - Unit 3 lessons 16-21

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

CSCI 3300 Assignment 3

Lesson 7: If Statement and Comparison Operators

Working with JavaScript

Programming language components

Task 1. Set up Coursework/Examination Weights

CMPT 100 : INTRODUCTION TO

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017)

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

CSCI 3300 Assignment 3

Javascript Lesson 3: Controlled Structures ANDREY KUTASH

introjs.notebook March 02, 2014

COMP519 Practical 5 JavaScript (1)

Chapter 17. Fundamental Concepts Expressed in JavaScript


Princess Nourah bint Abdulrahman University. Computer Sciences Department

COMS 469: Interactive Media II

Arrays Structured data Arrays What is an array?

Week 1 - Overview of HTML and Introduction to JavaScript

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users

JAVASCRIPT BASICS. Type-Conversion in JavaScript. Type conversion or typecasting is one of the very important concept in

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

CIS 228 (Spring, 2012) Final, 5/17/12

CITS1231 Web Technologies. JavaScript Math, String, Array, Number, Debugging

Such JavaScript Very Wow

Project 2: After Image

Unit 6 - Software Design and Development LESSON 4 DATA TYPES

COMP284 Scripting Languages Lecture 14: JavaScript (Part 1) Handouts

For Project 1H, you will need the following file: w01h_casting_call You will save your document as: Lastname_Firstname_1H_Casting_Call

COMPSCI 120 Fall 2017 Review Questions for Midterm #2 Professor William T. Verts

(Simple) JavaScript Framework Homework

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

Boolean evaluation and if statements. Making decisions in programs

CSCI 3300 Assignment 6

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11

write vs. writeln Prompting as Page Loads Today s Goals CSCI 2910 Client/Server-Side Programming Intermediate File vs. HTML Output

Lecture 14. Introduction to JavaScript. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

SELECTION. (Chapter 2)

Introduction to Computer Science and Business

1/6/ :28 AM Approved New Course (First Version) CS 50A Course Outline as of Fall 2014

Creative Computing Course Syllabus 1 semester for High School (110 contact hours)

CECS 189D EXAMINATION #1

CSCI 3300 Assignment 4

CSC Web Programming. Introduction to JavaScript

Client-Side Web Technologies. JavaScript Part I

PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

Internet & World Wide Web How to Program, 5/e by Pearson Education, Inc. All Rights Reserved.

CIS 1350 Final Project Part 1 of 4

JavaScript: Control Statements I Pearson Education, Inc. All rights reserved.

Exercise 1: Basic HTML and JavaScript

Mark Scheme. Additional Sample Assessment Materials. Pearson BTEC Level 3 - Computing. Unit 1: Principles of Computer Science

Course Description This one-day instructor-led course provides students with an overview of the features and functions of Microsoft Word 2010.

PIC 40A. Midterm 1 Review

GRAPHIC WEB DESIGNER PROGRAM

Assignment 2: Website Development

2018 Computing Science. National 5. Finalised Marking Instructions

ITSE 1411 Beg. Web Programming

Functions, Randomness and Libraries

Guidelines for doing the short exercises

Outcomes Week 2 Overview Describe the inputs, activities, and outputs of each step in the software development life cycle. Describe arithmetic, relati

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.

CSCI 3300 Assignment 7

Software Development Techniques. 26 November Marking Scheme

HTML5 and CSS3 More JavaScript Page 1

CS1110 Lab 6 (Mar 17-18, 2015)

CSCI 3300 Assignment 7

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

Object Oriented Programming with Java

Graded Project. Microsoft Excel

Important Java terminology

while (condition) { body_statements; for (initialization; condition; update) { body_statements;

Variables and Functions. ROBOTC Software

var num1 = prompt("enter a number between 1 and 12","1"); var promptstring = "What is " + num1 + " times 3?"; var num2 = prompt(promptstring);

CS 106 Introduction to Computer Science I

Software Development Techniques. December Sample Exam Marking Scheme

Authoring Numerical Problems in LON- CAPA: Step- by- Step

COMP 202 Java in one week

Assignment front sheet

INFS 2150 Introduction to Web Development and e-commerce Technology. Programming with JavaScript

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Objectives. Introduction to JavaScript. Introduction to JavaScript INFS Peter Y. Wu, RMU 1

Title: Jan 29 11:03 AM (1 of 23) Note that I have now added color and some alignment to the middle and to the right on this example.

Year 8 Computing Science End of Term 3 Revision Guide

CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have

Decisions, Decisions. Testing, testing C H A P T E R 7

Session 3: JavaScript - Structured Programming

ChipRider AQA GCSE Computer Science Mobile Assignment

3 The Building Blocks: Data Types, Literals, and Variables

Text Input and Conditionals

Coding in JavaScript functions

CGS 3066: Spring 2015 JavaScript Reference

Graded Project. Microsoft Excel

Transcription:

Lab 1 Concert Ticket Calculator Purpose To assess your ability to apply the knowledge and skills developed in weeks 1 through 3. Emphasis will be placed on the following learning outcomes: 1. Create and display simple syntactically correct HTML documents. 2. Describe the execution a JavaScript program in a web browser. 3. Write and call functions that utilize parameters and return values. 4. Declare, define, and use variables in a script. 5. Correctly use the JavaScript "if" and nested "if-else if" statements. Assignment Your local school is going to host a concert. They need a web page for the school staffs to determine the concert ticket costs. You are tasked to design and build the concert ticket calculator for the school. There are four type of tickets. They are front row, middle row, rear row and balcony. The ticket costs are. Front row: Middle row: Rear row: Balcony: $12.50 per ticket $10 per ticket $7.50 per ticket $14.50 per ticket Presume all seats are purchased at once and are in the same seating location. Regardless of location, if 6 or more tickets are purchased, 12% will be deducted from the final total. Students get additional 15% discount. For example, for 8 tickets without student discount, the web page should output: Front row seats for 8 tickets will cost $88.00 Middle row seats for 8 tickets will cost $70.40 Rear row seats for 8 tickets will cost $52.80 Balcony seats for 8 tickets will cost $102.08 For 8 tickets with student discount, the web page should output: Front row seats for 8 tickets will cost $74.80 Middle row seats for 8 tickets will cost $59.84 Rear row seats for 8 tickets will cost $44.88 Balcony seats for 8 tickets will cost $86.77 12.50 x 8 = 100. 12% discount for 6 or more tickets, the total ticket cost is $88.00. And for student 15% discount, the total ticket cost is $74.80. Verify the calculation.

Action Items/Programming Requirements The solution must use and deliver both an HTML and a JS file. The JS file must be referenced in the <head> tag of the HTML document using the <script> tag to load your function so it can be called later on. The solution should use a <script> in the <body> of the HTML to call the main weather function. All JS files must contain the strict directive at the top. This directive allows the debugger to flag undeclared variables. "use strict"; All variables must be declared. The prompt() function must be used to gather information from the user just as was done in the example screen shots. Do not use <input> tags or hard coded input values. If function has parameters, the function parameters must be utilized. No global variables are allowed. Function Requirements You should have these functions. o A ticket calculation condition function: This function three parameters: Seating location such as Front, Middle, Rear, or Balcony Number of tickets Is student Boolean The function must be in a JS file. All functions should always be in JS files and multiple separate functions can be in the same JS file. The function is responsible for calculating and returning the total ticket cost for the requested number of tickets for the given seat location with or without student discount. Your function should be reusable. If done correctly, the parameters provide everything needed to calculate the ticket cost. Call the function four times to get the information you need for all output. The code inside the function may NOT prompt the user nor write to the web page. The function parameters are sufficient to allow the function code to calculate the costs and return the answer. The JavaScript that calls the function should handle prompting and output to the web page. The calling code should output four HTML bullet points displaying the total cost of the requested number of tickets for seating at ALL four seating locations. o An utility isstudent function: Return true if user answers "Y" or "y" to student discount question. False otherwise. See the sample output screen shots. o (Optional) A main function: Having a main function help organize the overall flow of the program. This function prompts for user inputs and call the ticket cost calculation function and displays the results. Put the HTML and JS files in the same folder. Try to make your solution look similar to the screen shots. Put identifying information in your files: your name, assignment name/number term/class.

Example for HTML: <!-- YourName Lab 1 2017-SU-ITEC136 --> Example for JS: /** * @author YourName * Lab 1-2017-SU-ITEC 136 */ Review code against the documentation and style requirements Word document available on the course web site for the assignment. You will find that both documentation and style requirements are facilitated by the Aptana Integrated Development Environment (IDE).

Screen Shots (FireFox): With student discount:

Screen Shots (FireFox): Without student discount:

Helpful Hints The following hints may help you to solve the problem: The JavaScript file must have "use strict"; directive. Use the prompt() function to input data. For example: var favcolor = prompt("what is your favorite color?", "yellow ); The first parameter is shown to the user and the second parameter is the optional default response. Recall that prompt() returns a string value. Use the parsefloat() function to convert a string into a floating point number. After the JavaScript below, receipttotal will hold a floating point value with decimal precision, ready to be used in math operations. Likewise, num variable can have decimal value. var numberasstring = "6.023"; var receipttotal = parsefloat(numberasstring); var num = parsefloat(prompt("what is 5 / 2?")); Use the parseint() function to convert a string into an integer number. After the JavaScript below, totalpeople will hold a whole number value of 123, ready to be used in math operations. Likewise, age variable only hold integer value. var totalpeopleasstring = "123"; var totalpeople = parseint(totalpeopleasstring); var age = parseint(prompt("how old are you?")); Use the tofixed() method of any Number object (variable) to convert a number into a string with a fixed number of decimal places. For example: var mypi = 3.1415926535; document.writeln(mypi.tofixed(4)); // writes out 3.1416 Use Math.round() to round a number to the nearest integer only. var wholenum = Math.round(20.49); // Returns 20 into wholenum wholenum = Math.round(20.99); // Returns 21 into wholenum You could use the.tofixed() method of any Number object (variable) to convert a number into a string with a fixed number of decimal places. But.toFixed() is meant to convert to strings, not round number variables. Additionally, while.tofixed() may round most values, there is a problem with it on some numbers. For example, this works fine: var mypi = 3.1415926535; document.writeln(mypi.tofixed(4)); // writes out 3.1416 This does not:

var val = 1.045; var n = val.tofixed(2); document.writeln("n == " + n + "<br>"); // 1.04, WRONG! Should be 1.05 Use the following to properly display number to the 2 decimal place, var val = 1.045; val = Math.round(val * 100)/100; var n = val.tofixed(2); Better yet, write a function to return the number with two decimal places. function round(value) { return (Math.round(value * 100) / 100); } var val = 1.045; var n = round(val).tofixed(2); If a variable represents U.S. currency, we expect to see it displayed with two places of decimal precision. Even if there is only one place of decimal precision in the value. For example, a variable holds 1.5; when output to the web page it will appear as 1.5 this rather than 1.50 as preferred. Even though.tofixed() isn't a good choice for rounding, it is very good at zero padding. Use it for output of monetary values as calculated values may have only one decimal place of precision. Use document.writeln() to display output to user.

Grading Criteria Quality of the solution: 0 50 points o Documentation (internal comments) (0 5 points) It is not uncommon for industry to impose a way of documenting software that is uniform across all programmers. Documentation standards are outlined in the same document referenced in the style bullet below. o Style (formatting, naming conventions and appearance of solution code) (0 5 points) As listed in the action items of the course web page lab assignment, ensure that your solution code meets the documentation and style guidelines for this course. The documentation and style requirements Word document titled "DocumentationAndStyleGuidelines.doc exists in the Resources folder on your course CD and as a link on the lab assignment page web page. Review your code against this document. I am looking for consistency also. For example, if you prefer to put your curly braces on the same line as the if statement rather than the next line, that is fine provided you are consistent throughout your code. o Correctness (how the program works under test) (0 40 points) The program should work, and be seen to work. The code should be robust. Note that grammar, spelling, and writing mechanics do not contribute to the total points for this assignment; however, improper grammar, poor spelling, or poor writing mechanics may result in significant point deductions.