Recent Question/Assignment

UNIVERSITY OF SOUTHERN QUEENSLAND
CSC1401 - Foundation Programming (Semester 1, 2016)
Assignment 1 Specification
Days-To-Go
Due Date: 27 March 2016
Weight: 8 %
Goals and Topics
The assignment problem is straightforward. All necessary details have been supplied. The solution of the problem will be straight line code which will use the programming concepts and strategies covered in Workshops 1-3. The subgoals are:
- Understanding values, variables and constants, Objects, Operations, and Functions
- Translating simple design into JavaScript code
- The mechanics of editing, interpreting, building and running your program
- Testing your program
- Commenting your source code
- Becoming confident and comfortable with programming in small problems
Your Task
“Days-to-Go” is an interesting and useful feature in website design. It shows up the remaining number of days (or even with hours, minutes, and seconds) towards an event. For example, at anytime you visit the official website of Rio 2016 Olympic Game , you will see such a feature showing the number of days, hours, minutes and seconds towards the starting date of Rio 2016. In this assignment, you are going to write a JavaScript program to implement the “Days-To-Go” feature.
The Concept of Time in JavaScript
In JavaScript a time is defined as a Date Object. Each date object stores its state as a time value, which is a primitive number that encodes a date as milliseconds since 1 January 1970 00:00:00 UTC. Thus, a date later than 1 January 1970 00:00:00 UTC will have a positive time value, whereas an earlier date will have a negative time value. On the basis of the common timeline (which we all live on), the distance between any two dates can be calculated using their time values in milliseconds. Figure 1 illustrates the concept, where C is a date earlier than 1 January 1970 00:00:00 UTC, and A and B are later with B being further than A.

Figure 1: The Difference Between Two Date Instances
Functional Requirements
Constants and Variables
Within the script section, create constants and variables following professional conventions and initialise them using right values. Some constants and variables have been suggested in the following tables. You should create more when necessary.
Table 1: Constants
Description Value
Number of milliseconds in a day 1000*60*60*24
Number of milliseconds in an hour 1000*60*60
Number of milliseconds in a minute 1000*60
Number of milliseconds in a second 1000
Table 2: Variables
Description Initialising value description Type
Name of the event The name of Rio 2016 Olympic Game String
Year of the event The year of Rio 2016 Olympic Game Number
Month of the event The month of Rio 2016 Olympic Game Number
Day of the event The day of Rio 2016 Olympic Game Number
Calculation
1. Create a Date object for the date of the event by using the variables created previously.
• Send the object constructor the variables (not values) for year, month, and day of the event;
• Mind the order of arguments sent to the constructor;
• Note that month numbers begin at 0 for January, 1 for February, and so on;
2. Create a Date object for the current time.
• No arguments need to be supplied to the constructor.
3. Calculate the difference between the current time and the event time:
• Use the getTime() member function to get a Date object’s time value in milliseconds
• Deduct the time value of current time by using the value of event time.
4. Calculate the number of days to the event:
• Divide the time value difference by the number of milliseconds in a day.
• Use the Math.floor() function to reduce the result number to an integer.
5. Calculate the number of hours, minutes, and seconds in the remaining time value:
(a) Mod the time value difference by the number of milliseconds in a day;
(b) Divide the mod result by the number of milliseconds in an hour;
(c) Use the Math.floor() function to reduce the number to an integer for the number of hours;
(d) Repeat Steps (a) to (c) to calculate the number of minutes and seconds. You may need to update the calculating formula accordingly.
Presentation
Figure 2 shows a sample output when running the “DaysTo-Go” program. Note that
- the information should be displayed using the alert() function;
- wherever possible you should use variables in expressions instead of explicit values (e.g., literals and num-
bers), for example, using the variable created for the event name instead of a string value of “RIO 2016 ”; Figure 2: Illustration of the Output
- the layout of output may vary depending on web browsers.
Testing
Test your program by comparing its calculating results to the Days-To-Go feature on the official website of Rio 2016 (http://www.rio2016.com/en). Note that due to different locality settings on your computer and the Rio 2016 server, your calculation result could be slightly different from that shown on the Rio 2016 website. For example, in a test when my program said “182 DAYS” to go, the Rio 2016 website showed “183 DAYS” – Australia is in almost one day ahead of Rio de Janeiro. Such a difference is not an error and is acceptable.
Non-functional Requirements
Structure of the Source Code
- All code should appear in the script section in the head of the HTML document.
- Do not write any code in the HTML body. All functionality are delivered by JavaScript.
- In the script order your code as follows:
(a) Constants;
(b) Variables and objects (declared and initialised); (c) Other statements.
Comments
- You are required to add at least three comments to the source code.
- Do not comment every single line, instead, comment on blocks of code with a common purpose.
- Do not simply translate the syntax into English for comments, instead, describe the purpose of blocks of code.
Submission
What You Need to Submit – Two Files
For a complete submission you need to submit two files as specified below. You can submit them individually or compress them and submit a common .zip (or .rar) file. The assignment submission system will accept only the files with extensions specified in this section.
1. Statement of Completeness in a file saved in .pdf format in 200-300 of your own words describes:
- The state of your assignment, such as, any known functionality that has not been implemented, etc. (It is expected that most people will implement all of the functionality of this assignment.)
- Problems encountered, such as, any problems that you encountered during the assignment work and how you dealt with them;
- Reflection, such as, any lessons learnt in doing the assignment and suggestions to future programming work.
2. The program in a file saved with an .html extension contains the source code implemented following the functional and non-functional requirements.
Late Submission and Extension Request
Please refer to USQ Policy Library - Assessment Procedure for information on the late submission policy and USQ Policy Library - Assessment of Compassionate and Compelling Circumstances Procedure for considerable special circumstances in extension request.
The Extension Request Form is available on the course’s StudyDesk. Should you need to request an extension please fill the form and email it to the Course Examiner with supportive documents (e.g., medical certificate or endorsement letter from supervisor in workplace) prior to the due date . Please note that any requests without supportive documents will be declined straigthway without consideration.
Marking Criteria
The assignment will be marked out of 16 and scaled down to a grade out of 8. Table 3 presents the marking criteria. If all criteria are satisfied you will receive 16 marks. If not all criteria are met, part marks may be given. Check your own submission against these criteria before you submit.
Table 3: Marking Criteria
ID REQUIREMENTS MARK
Statement of Completeness
1 The statement is in appropriate length of 200-300 of student’s own words 1
2 The “State of assignment” reflects the true state of completeness 1
3 The “Problems encountered” discusses problems and dealing strategies 1
4 The “reflection” discusses learnt lessons and reasonable suggestions 1
Subtotal 4
Functional Requirements
5 The program is running without any syntax errors 1
6 All constants and variables are declared and initialised appropriately before use 1
7 The event’s Date object is created correctly 1
8 The difference between two times (the event and now) is calculated using appropriate strategy 1
9 The number of days to go to the event is calculated correctly 1
10 The number of hours is calculated correctly 1
11 The number of minutes and seconds are calculated correctly 1
12 The calculating result is displaying appropriately 1
Subtotal 8
Non-functional Requirements
13 The program has a complete structure including all head, body, script sections defined by appropriate tags 1
14 Identifiers of variables and constants are following professional conventions 1
15 Constants and variables are used in calculation and expression instead of explicit values 1
16 At least three comments are added to describe the purpose of blocks of code 1
Subtotal 4
TOTAL 16
Suggested Strategy
You have three weeks to finish the assignment. Plan to complete it on time. Do not write all of the code in one sitting and expect that everything will be working smoothly like a magic.
First week Read assignment specification, clarify anything unclear by putting a post on the Assignment 1 Forum, think about how to do it, how to test it, devise high-level algorithms for each independent part of the assignment. Begin to type program (with comments), in incremental stages. Seek help on assignment forum if needed.
Second week Re-read the specification, continue to refine design of various sections to code, bring up any problems to the assignment forum if necessary. Finish initial coding.
Third week Fully test the program; have another review on the source code; re-read the specification (especially marking criteria) to make sure you have done exactly what is required. Document the ”Statement of Completeness”.

An HTML file with the Javascript Source Code


Buy Now at $19.99 USD
This above price is for already used answers. Please do not submit them directly as it may lead to plagiarism. Once paid, the deal will be non-refundable and there is no after-sale support for the quality or modification of the contents. Either use them for learning purpose or re-write them in your own language. If you are looking for new unused assignment, please use live chat to discuss and get best possible quote.

Looking for answers ?