Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Case Study Expert

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 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 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.

2436_Difference Between Two Date Instances.jpg

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 "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

887_Difference Between Two Date Instances1.jpg

Figure 2: Illustration of the Output

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.

Case Study, Writing

  • Category:- Case Study
  • Reference No.:- M91729251
  • Price:- $70

Guranteed 36 Hours Delivery, In Price:- $70

Have any Question?


Related Questions in Case Study

Theory identification and analysisassignment overviewthree

Theory Identification and Analysis Assignment Overview Three of the four assignments in this course deal with the place of theory in social work practice. A solid understanding of the theoretical basis for understanding ...

Rationalesafety and risk management are critical aspects of

Rationale Safety and Risk Management are critical aspects of a workplace and breaches are punishable under Work Health and Safety Law. This task encourages students to analyse and conceptualise responses to safety breach ...

Safety management planwrite and submit for assessment a

Safety Management Plan Write and submit for assessment a Safety Management Plan for an organisation of your choice. There are many models that you can use to base your Safety Management Plan on. Some models include the m ...

Assignment - media evolution analysisassignment details

Assignment - Media Evolution Analysis Assignment details: Following our lectures and discussions in class, choose one media technology or phenomenon and research its historical trajectory. In particular, you should focus ...

Safety and risk managementcritical review case analysisread

Safety and Risk Management Critical Review: Case Analysis Read the online article at the following link: Canberra construction company fined $1.1 million over death of truck driver by Gordon Taylor In an essay describe t ...

This paper will consist of an ethical analysis of the bp

This paper will consist of an ethical analysis of the BP oil spill. There is one source provided to start this research, cite at least four other sources. This source has a particular case because it has an interesting a ...

Assessment task - reflectiona reflection on growth

Assessment Task - Reflection A reflection on growth, development and ageing in exercise science careers Unit Learning Outcome (s) assessed This assessment task will assess your ability to apply key concepts of growth, de ...

Answer the questions using volkswagen group- write on this

Answer the questions using Volkswagen Group- write on this topic Case Assignment Please select a company from among the ones listed below (see Articles for Case Assignment) or else select an organization of choice facing ...

Assignment -read the hefty hardware case study and answer

Assignment - Read the Hefty Hardware Case Study and answer the questions. Discussion Questions 1) Overall, how effective is the partnership between IT and the business at Hefty Hardware? Identify the shortcomings of both ...

Task 1 just the factsinstructions- read the statement below

Task 1: Just the Facts Instructions - Read the statement below carefully. - Conduct some research and write down your answers in the space provided. An Australian Culture Overview Australia is a vast island continent sit ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As