1. Page 1 / 6
M150A
Tutor-marked Assignment 1 - Fall 2010
Cut-off date: November 28, 2010
This TMA should be submitted to your tutor electronically through the LMS system
before the cut-off date indicated at the beginning of the TMA.
You should write your solutions to the questions in a single word document. Head the
document with your name and your Personal Identifier.
This TMA assesses your understanding of Units 1, 2, 6 and 7 of M150.
It consists of 5 quesƟons. The total marks for each quesƟon are shown at the beginning
of each question. The marks allocated to each part of a question are indicated in the
margin.
You should be able to answer the questions of this TMA once you have completed the
units each question covers:
QuesƟon 1: Unit 1
QuesƟon 2: Unit 2
QuesƟon 3: Unit 6
QuesƟon 4: Unit 7
QuesƟon 5: Unit 7
Arab Open University
Faculty of Computer Studies
M150 Data, compuƟng and informaƟon
2. Page 2 / 6
QuesƟon 1 [10 marks]
1. Read secƟon 8.2 of the M150 course companion (You should have had a copy of
it with the course material and you can also view a soft copy of it in the course
CD ROM 11). [4]
a. Briefly define the two terms syndication and plagiarism.
b. How can you avoid syndication and plagiarism when writing your TMAs?
2. Computers are tools for finding. Explain this with examples. [2]
3. What two advices can you give for people who make online shopping? [4]
Question 2 [10 marks]
1. People are using computers to communicate with other people. [5]
a. Explain how computers are extending human to human communication
with examples.
b. Define the term Netiquette.
c. Go to the following URI and make the online quiz about Netiquettes:
http://www.albion.com/netiquette/netiquiz.html.
Based on what you’ve learned from the quiz, answer the following
questions:
• What must you do before you post in a discussion group such as
the discussion forum in your LMS system?
• What’s the importance of knowing the Netiquettes?
• What is the Golden Rule of Netiquette?
2. Representations play a central role in facilitating communication by establishing
a relationship between some form and some meaningful content subject to
some convention; mention the two conditions for effective representation. [2]
3. From your understanding of the term “complex representation”, briefly explain
how does implementing them help in creating and interpreting new traffic signs?
[3]
Question 3 [25 marks]
1. Programs written in high-level languages need to be translated into machine
language before being processed. Mention two different mechanisms for doing
this translation process. Give examples of programming languages for each one
of them. [4]
2. What is an operating system? What functions it does? Give two examples of an
old text-based operating system and a new one. [4]
3. The following flowchart diagram shows a loop structure problem: [11]
3. Page 3 / 6
a) From the diagram, specify:
The condition, the loop body, and any instruction(s) that is (are) not in
the loop body.
b) Complete the following simple tracing table for the diagram in figure 1.
You may provide an alternative table that shows that you’ve traced the
diagram above.
number (number is 0)
NOT
(number is 0)
Go into
the loop??
Iteration
number
number output
12 False True Yes 1 9 12
.
.
.
No (Stop)
c) How many times will the loop body be executed?
d) What is the output after these instructions have been executed?
e) What do you expect to happen if the statement (decrement number by 3)
is replaced by (increment number by 2)? Why?
4. Page 4 / 6
4. Truth tables can be used to show whether or not two Boolean expressions are
equivalent. Complete the truth tables given below to show that: [6]
NOT (A OR B) is not equivalent to NOT A OR NOT B
Make sure that you end your answer with a proper conclusion.
A B (A OR B) NOT (A OR B)
True True
True False
False True
False False
A B NOT A NOT B NOT A OR NOT B
True True
True False
False True
False False
Question 4 [25 marks]
1. Write JavaScript code equivalent to the flowchart shown in Figure 1 in QuesƟon
3 above. [7]
2. Trace the following JavaScript code and specify the output: [6]
a. var aString = 'M150';
for ( var i = 0; i < aString.length; i = i +1 )
{
document.write(aString.charAt(i) + '<BR>');
}
b. var x = 0, y = 0;
for(var i=0; i <= 5; i++)
{
x = x + 1;
y = y + x;
}
document.write(x,y);
c. var x = 100;
if ((x >= 0) && (x!= 100))
x = x * 10
else
x = x * 20;
document.write(x);
5. Page 5 / 6
3. The following JavaScript codes will not work or will not produce the expected
output. Find the errors/mistakes in these JavaScript codes, and then rewrite
them after correction. [6]
a. var age;
age = window.prompt('Please enter your age','');
age = 20 + year;
document.write('After 20 years you will be '+age + '
Years old');
b. var moneyAmount, zakat;
zakat = moneyAmount * 2.5 /100;
document.write ('The zakat of your money is: ' + zakat
+ ' KD');
c. var answer;
answer = window.prompt('Are you enjoying programming
with JavaScript? Yes/No', '');
if ((answer = 'Yes')|| (answer = 'yes'))
{
document.write('Glad to hear that!' + '<BR>');
}
else
{
document.write('You will enjoy it soon with more
practice and patience!' + '<BR>')
}
4. Write JavaScript code to calculate and print the area and the circumference of a
circle as follows: [6]
• Define 3 variables: radius, area and circumference.
• Ask the user to enter the radius of the circle.
• Calculate the area and the circumference of the circle based on the formulas:
area= 3.14 * radius * radius
circumference = 2 * 3.14 * radius
• Print the calculated area and circumference in the output window.
6. Page 6 / 6
Question 5 [ 30 marks]
1. A social association is making a study on the effect of TV on small children. One
of the things they need in the study is the average number of hours children
spend in watching TV daily.
Taking into consideraƟon a sample of 30 children, write a complete JavaScript
program that reads the number of hours that these children spend in watching
TV in a day, calculate the average and print it in the output window. [12]
2. A new restaurant offers free delivery within a three-mile radius, that is, up to
and including three miles from their location. [15]
For distances over three miles and not exceeding 12 miles, there is a charge of
£1 per extra mile over the first three.
a. Write a complete JavaScript program which will work according to the
following specifications:
• Read the distance in miles from the user.
• If the distance is within three miles(i.e. less than or equals to 3), the
user should be informed that the delivery will be free;
• If the distance is over three miles but not over 12 miles, the user
should be informed what the delivery charge is in pounds. To do this,
you need first to calculate the extra distance. You should store the
value in the variable which is already declared, then use this variable
when you output the message.
• If the distance exceeds 12 miles, the user should be informed that the
company’s maximum delivery distance is 12 miles.
b. Run your program with each of the following inputs:
• 1
• 5
• 15
For each test, insert a screen dump showing the output into your Solution
Document.
Important note: In your answers to both parts 1 and 2 (a) of this
question; you should follow good programming style that helps
readability. This includes: [3]
• Using comments stating the purpose of your program.
• Selecting meaningful variables names.
• Using spacing and indentations to help make the structure of your
program clear.