Programming concepts

Assignment Help Programming Languages
Reference no: EM13762567

Java Script Days to GO

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 condent 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 ocial website of Rio 2016 Olympic Game1, 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 dened 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. CSC1401 Assignment 1 Specication { Days-To-Go 2

Figure 1: The Dierence 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;

2. Create a Date object for the current time. No arguments need to be supplied to the constructor.

3. Calculate the dierence between the current time and the event time: CSC1401 Assignment 1 Specication { Days-To-Go 3 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 dierence by the number of milliseconds in a day. Use the Math.
oor() 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 dierence 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.
oor() 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: Illustration of the Output
Figure 2 shows a sample output when running the \Days- To-Go" program. Note that

- the information should be displayed using the alert() function;
- wherever possible you should use variables in expres- sions 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";
- 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 ocial

Such a dierence 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. CSC1401 Assignment 1 Specication { Days-To-Go 4
- 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 les as specied below. You can submit them individually or compress them and submit a common .zip (or .rar) le. The assignment submission system will accept only the les with extensions specied in this section.

1. Statement of Completeness in a le saved in .doc, .docx, .odt, .rtf or .txt 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 as- signment work and how you dealt with them;
- Re ection, such as, any lessons learnt in doing the assignment and suggestions to future
programming work.
2. The program in a le 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 ll the form and email it to the Course Examiner with supportive documents

(e.g., medical certicate 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.

Reference no: EM13762567

Questions Cloud

Write two second order differential equations : Write two second order differential equations which describe the forces on each mass. Do this in the comments of your code. (Hint: Newton's Law F=ma, Hooke's law F=-kx.,F=Force, m=mass, a=acceleration, k=spring constant, x=displacement from equili..
Argument for using a job-costing system : Create an argument for using a job-costing system, given the ability to compare actual costs with estimates or budgeted amounts during the manufacturing process or duration of a project on management decisions. Provide a specific example of one be..
The atmosphere due to photosynthesis. : Life existed in the ocean for almost 3 billion years BEFORE it moved out on to land.
Write two essay on nancy chodorow and carlos astrada : Write two essay on Nancy Chodorow and Carlos Astrada. For each essay, remember to introduce your topics with a concise thesis statement and follow up with supportive arguments.
Programming concepts : 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:
The social, economic, and environmental perspectives : This issue is important for humans, wildlife and the environment.
Discuss the pros and cons of a gold standard : Developing countries have more severe output costs of exchange rate crises and take longer to recover from exchange rate crises. Discuss three reasons why may be the case - domestic nominal and real interest rate, the exchange rate, domestic consum..
Manufactures two types of vases : Rose Incorporated manufactures two types of vases, small and large. The following per-unit data are available.
Discuss how bundren interprets each of their stares : how the Bundren children stare at him when he arrives at the river bank. Discuss how Bundren interprets each of their stares.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write program for department of motor vehicles

Department of motor vehicles has finally decided to computerize its list of licensed drivers. Program you write must make use of existing file call Licenses with records of given form. Name, License Number

  Give greedy algorithm to get all n people across bridge

Give a greedy algorithm to get all these n people across the bridge in a fastest way. Describe the algorithm briefly. Prove the correctness.

  Pseudocode for a program to solve mathematical problem

Pseudocode for a program to solve the following problem. A student borrows $3,000 at an interest rate 2% per month on the unpaid balance.

  Design application to allow user to input a price

Design an application that allows a user to input a price until an appropriate sentinel value is entered.Output is the price of each item on each day,one through seven.

  Write program that merges two files

The first programming project involves writing a program that merges two files that contain polynomials. To merge two files, the input files must be in sorted order.

  Computing average net profit per sale of product

Your company bought 250,000 online advertising impressions and made average net profit per sale of product of $5.

  Write a regular expression for the given problem

You need to prepare a regular expression of the problem - The set of strings over alphabet {a, b, c} containing at least one a and at least one b.

  How large a value can be stored in an integer variable

Describe a representation for integers that has no size restriction (other than the limits of the computer's available main memory)

  Find out the total of balances

Display all the contents of the file in a tabular format with the first row being a header row and write to a file that is called account numbers.txt only the account numbers from the read file.

  Create mock level design for game

Write a 5-page "mock level design" in which you design a level for a game. The game is a shooter, the level is an old warehouse filled with zombies and demons with a boss at the end.

  Write a function word_counts

Write a function word_counts that parses the string s into words and returns an array (of arrays of the form [word, count]) representing the frequency of each word. Words are case-insensitive:

  Explain usability and accessibility in site design

A description of content to be included in site and how this content will be acquired. Attention should be given to copyright restrictions.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd