Write javascript program to implement days-from-birth


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 sub goals are:

i. Understanding values, variables and constants, Objects, Operations, and Functions

ii. Translating simple design into JavaScript code

iii. The mechanics of editing, interpreting, building and running your program

iv. Testing your program

v. Commenting your source code

vi. Becoming confident and comfortable with programming in small problems

Task: "Days-From-beginning" is an interesting and useful feature in website design. It shows up how many days (or even with hours, minutes, and seconds) after an event started. For example, a feature of Days-From-Birth shows the number of days after the date of birth. In this assignment, you are going to write a JavaScript program to implement the "Days-From-Birth" feature.

Functional Requirements:

Constants and Variables:

Within the script section, create constants and variables following professional conventions and initialize them using right values. Some constants and variables have been suggested in the following tables. You should create more when necessary.

Calculation:

1. Create a Date object for the date of birth by using the variables created previously.

Use one prompt function to input the name of user as Figure 2.

Use another three prompt functions to input the year, month, day of the birth one by one and then transfer them to the Date constructor.

Mind the order of arguments sent to the constructor;

Note that month numbers in Date constructor begin at 0 for January ('1' entered in prompt function), 1 for February ('2' entered in prompt function), 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 birth time (assume it is the starting time 0:00:00 a.m. on the Date of birth):

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 from the birth:

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.

Presentation -

Figure 3 shows a sample output when running the "Days-From-Birth" 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 numbers), for example, using the variable created for the user name instead of a string value of "Lily"; "XXXX" is the number of days from the date of birth.

- the layout of output may vary depending on web browsers.

Testing - Test your program by enter your own date of birth to see whether the outcome is correct or not.

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 initialized);

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

Note - All required figures and information are in attached files.

Foundation Programming Assignment Help, Homework Help service is a better option to grasp, as tutors aim to offer the best online assistance to score top-notch grades.

Tags: Foundation Programming Assignment Help, Foundation Programming Homework Help, Foundation Programming Coursework, Foundation Programming Solved Assignments

Attachment:- Foundation Programming.rar

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write javascript program to implement days-from-birth
Reference No:- TGS03046788

Expected delivery within 24 Hours