M150 Data, computing and information
Question
1 [20 marks]
1. Write JavaScript
program according to the following: [20]
a. Define a function
called findMax
which
takes an array argument and returns the maximum number in the array.
b. Define two arrays
of numbers:
- The first array is initialized on
declaration. It has 5 elements of your choice.
- The second array has 6 elements and
is initialized by values entered by the user (in a loop). Enter the values
of your choice.
c. Call the function findMax to find the maximum
number is the two arrays. Print the returned numbers in the output window. You
need also to print the elements of both arrays.
d. Provide a
screenshot of the output of your program. Make sure that the output includes
the elements of both arrays and the maximum number in each one.
Question
2 [20 marks]
In unit9, page 21 you were introduced to the methods associated with Date object. In the same
unit, section 4.2 you learned how to use functions from the
"dateLibrary.js" in JavaScript programs. The specifications for all
the functions in this library are in Appendix 1 at the end of unit 9.
Write JavaScript
statements to do the following:
a. Create the date 7
June 2000 and assign it to the variable date1.
b. Create the date 18
May 2020 and assign it to the variable date2.
c. Calculate the
difference in days and years between date1 and date2
and print
them in the output window.
d. Change the month of
date1 to be September and print the new value in the output window.
e. Change the year of date2
to be 2013
and print the new value in the output window.
f. Display the day
name of date1.
g. Display date1
in short
form.
h. Insert a snapshot
that shows the resulted output of parts d, e, f and g.
i. Provide a copy of
the specifications of all the functions you’ve used in writing your program.
j. What information do
we find in function specifications?
Question
3 [20 marks]
You are required to
model a new user-defined object type, Website.
The Website object type has the
following properties:
name:
a string variable representing the name of the website.
url:
a string variable representing the address of the website.
description: a string variable holding a brief description of the website.
The Website object type has the
following methods:
getName(): returns the name of the website.
getUrl(): returns the url of the website.
getDescription(): returns the description of the website.
display(): displays the name , url and description of the Website in an alert window.
The method should use the methods getName(),getUrl() and getDescription().
a. Write the Website constructor function Website(aName,aUrl,aDescription).
b. Implement the
methods getName(), getUrl(),
getDescription()and display() according to the above
specifications.
c. Prompt the user for
values of name, URL and description of a site he wants to create.
d. Create a Website instance and
initialize its properties by the values entered by the user.
e. Use an appropriate
method to print the Website instance information.
f. Run your program and
test it to make sure it works properly. In your Solution document insert two
screenshots: [3]
- one showing the program prompting
for the website
name,
with you having entered the name but not yet pressed OK;
- one showing the resulted alert
window.
g. Change the description of the Website instance.
h. Suggest another way
to change the description of the Website instance other than what you've done in g. Show the changes needed in
the program to implement it and give an example on how you are going to use it.
Question
4 [20 marks]
1. Discuss four
features of a good website. [4 marks]
2. Many computer users
think that the user interface through which they communicate with the computer
is the system. What are the impacts of having a poor UI system in an
organization? [3 marks]
3. The course book has
given you the definition for the term usability. Illustrate it using your own
words and understanding. [4 marks]
4. Login to the SIS
using your user name and password. Write a short paragraph discussing the
usability of the SIS, in your point of view. Do you think it is usable? Why?
Why not? How can we improve it? Give suggestions. [9 marks]