You are on page 1of 65

Course guide 

TCC 101
Computing I

Course Guide
ii WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

WOU Course team


Content Adapter: Mr. Sivakumar s/o Ramakrishnan
Course Coordinator: Dr. Bong Chin Wei
Instructional Designer: Professor Ng Wai Kong

Production
Editor: Mr. Terence Too Yang Yau
In-house Editor: Jeanne Chow
Graphic Designer: Audrey Yeong

Wawasan Open University is Malaysia’s first private not-for-profit tertiary institution dedicated to
adult learners.

It is funded by the Wawasan Education Foundation, a tax exempt entity established by the Parti
Gerakan Rakyat Malaysia and supported by the Yeap Chor Ee Charitable and Endowment Trusts,
other charities, corporations and members of the public.

© 2007 Wawasan Open University

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or
transmitted, in any form or by any means, electronics, mechanical, photocopying, recording or
otherwise, without prior written permission from WOU.

Wawasan Open University


51-20 Menara BHL,
Jalan Sultan Ahmad Shah,
10050 Penang.
Tel: (604) 2289323 Fax: (604) 2269323
Email: enquiry@wou.edu.my
Website: www.wou.edu.my
Course guide iii

Contents
Course Guide
1.0 Studying at WOU using the distance learning mode 1

2.0 How to succeed as a distance learner 3

3.0 The course − A brief introduction 5

About the course 5

Course organisation 8

Objectives 9

Outcomes 9

Continuous course assessment 10

Course delivery 12

Course material and student support 12

Course writer’s profile 14

4.0 Tutorials − Optimising tutorial sessions 15

Preparing for tutorials 15

Tutors 15

5.0 Examination 19

Examination policies 19

Passing marks 19

Assessment and examination 20

Specimen examination questions 20


iv WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

6.0 Supporting facilities 21

Hardware 21

Software 21

7.0 A word of encouragement 23

Appendix I − Tutor-marked assignment 1 25

Appendix II − Tutor-marked assignment 2 31

Appendix III − Tutor-marked assignment 3 37

Appendix IV − Specimen examination questions 45


Course guide 

1.0 Studying at WOU using the


Distance Learning Mode

W awasan Open University (henceforth abbreviated as WOU) welcomes you to


be a member of the community of learners. Advancing your education is one
of the most important investments that you can undertake. Hence, it is crucial that
you choose the right university to suit your needs. WOU wishes to assist you in your
decision-making. In this section, we will provide a brief account on how learning
takes place at WOU and how you can work and study simultaneously.

WOU has adopted the open distance learning mode as a key element to facilitate the
implementation of programmes that will provide you the opportunities for lifelong
learning. Our flexible learning programmes will meet the needs of working adults
who are unable to study on-campus full-time five days a week for four to five years
and yet yearn for an accredited qualification or personal interest enrichment without
leaving their homes and jobs.

While learning at WOU, you will be supported by comprehensive self-instructional


materials that are well designed and expertly written, an effective Learning
Management System (LMS) and a sound tutorial system. Technically, LMS is a
software application that uses computer programs to organise your coursework and
monitor your records and progress. The LMS, in time, will guide you through all the
stages of your learning life cycle (e.g., assess, learn, reinforce, support and validate)
to create the most effective learning experience for you.

The tutorial sessions are usually held at nights or weekends, either at WOU campus
or through strategically located and well equipped Regional Ofices. You can attend
your tutorial session at the Regional Office closest to your residence. A schedule
of the tutorial sessions will be sent to you at the beginning of the semester. These
sessions provide a platform for you to clarify any queries regarding your courses
with your tutor and for you to exchange ideas with your peers as well. This would
certainly boost your study skills and self confidence.

Your achievement in a course will depend on your performance in both the


continuous assessments and the final examination. In some cases, your attendance
at the compulsory day schools or laboratory sessions may also be considered.

Studying in an open distance learning environment for an award or qualification


demands great commitment from you. Although WOU provides you with a flexible
way of learning, you are required to complete assignments and sit for examinations
according to the schedule that has been specified.

In general, besides attending face-to-face tutorial sessions, you should be able to


allocate at least 6 hours weekly to study a course. If you are a working adult, it is
advisable to discuss your intention to further your studies with your employer as
well as your family members as their feedback can assist you in your decision. Their
support will greatly enhance your chance of success.
 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 

2.0 How to Succeed as a Distance


Learner

O pen distance learning (ODL), is a system of education in which education is


imparted to learners from a distance. The two (2) basic elements of ODL are:

1. The physical separation of instructor and learner.

2. The changed role of the tutor; who meets learners only for selected tasks
such as counselling, giving tutorials or collaborating with learners to
solve their problems.

In the conventional educational system, teaching content is communicated


by the instructor mainly by word of mouth. In distance education, however,
this inter-personal communication is replaced by print, telephone, electronic
communication (such as teleconference, audio and video systems), broadcasting,
on-line communication and others.

For you, the overriding benefit of ODL is that it gives you access to education that
you would not otherwise have. Only a minority of adults can afford to stop work
in order to further their studies. ODL allows you to study when and where it suits
you, and to enable you to continue learning while fulfilling commitments to work,
family or community.

You may be pursuing higher education for various reasons. You could be interested
in changing careers or you might simply want to expand your knowledge base for
work or personal reasons. You might even want to start a degree programme that
was postponed due to family or career needs.

In this regard, ODL is able to cater to your needs as you may not have the time,
financial resources, or educational background to be a fulltime student on campus.
Thus, distance education is a means to deliver accessible and affordable education to
you. It is important for you to bear in mind that in ODL, you are not working alone
on your long journey to a degree. Make full use of the facilities and opportunities
during your study at WOU, especially in getting to know fellow students with whom
you can work to achieve your dream.

You should always make an attempt to attend all scheduled tutorials, form study
groups with your peers, check for any latest update on the LMS, participate in e-
forums and contact your tutors. Your tutors are there to help you understand the
course materials, to clarify any subject matter you have difficulty following and to
collaborate with you to enhance learning. They are not there to give a lecture or to
answer your assignment questions for you. The email address and telephone number
of your tutor will be provided. You should also have your tutorial colleagues’ email
and phone contacts in order to work together. An active learning community can
ensure the successful completion of your course.
 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 

3.0 The Course – A Brief Introduction


About the course

TCC 101 Computing I is designed to provide a structured and stimulating


environment in which you can learn computing fundamentals using the object-
oriented paradigm (model) and Java technology. It aims to provide you with
the fundamentals of computing that would help to solve simple programming
problems.

The course is organised into 5 study units. These study units guide your learning.
Each unit contains three to four weeks of work and includes specific objectives,
directions for study, commentaries on the material presented in the text and
how to apply it. The titles of the specific study units are included in the course
overview table.

To help you review what you have learnt, the units include self-tests related to the
required readings, and activities to extend and apply your learning. These activities
and tutor-marked assignments assist you in achieving the stated learning objectives
of individual units and the course.

The time needed to complete the study units, work through the self-tests and
assignments and complete the rest of the course will vary from learner to learner.
You can adjust these times to fit your personal needs.

Each of the five units in this course contains three to four weeks of work. Make
sure you have planned your own study schedule. It is important that you complete
self-tests, assignments and the examination successfully and timely.

The course is structured so that each unit builds on previous knowledge. Each unit
includes at least four ways to help you study. These are:

1. Reading the study units.

2. Reading the textbook.

3. Completing the self-tests and activities that appear throughout the units;
these will require you to think, observe or undertake some activity that is
designed to help you apply the knowledge that you have gained.

4. Completing the assignments.

The average estimated time that you need to spend in this course is about six to
seven hours per week (average one hour a day). This estimate includes the time
for reading the study units and textbook, completing self-tests and practice exercises,
completing your assignments, undertaking the suggested reviews, attending tutorials
and preparing for your final examination.
 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

In general, we avoid duplicating the textbook material in the study unit. Instead,
we attempt to complement the textbook by presenting some of the more difficult
concepts in an alternate (and often simplified) way to help you understand them.
Often we present material which we think is important but that is not found in
the textbook. You should remember that the study unit is not meant to replace the
textbook, which is a good source of information in the course.

One final reminder is needed. Although you can adjust study times to suit yourself,
it is important that you complete and hand in your written assignments on time. You
need to bear this in mind when you are planning your study time. You can find
more information on assignments in a later section of this Course Guide.

Icons used in course materials (with examples)

In the course materials, you will come across icons that are designed to inform you
of the activities that you are required to do before proceeding to the next section of
the materials. Please follow the guidelines in these examples as the course writers
have included these icons in various activities of the course materials. The following
icons and descriptions explain how these icons lead you towards a richer and more
productive learning experience.

Activities Icons Description


1. Activity Circle the words that are used at the beginning
of “closed questions”.
why where did who when is
what how do would will can
2. Assignment Compare and contrast inflation with stagflation
by referring to books A & C and www.xyz.com.
Write a 600-word report on it.

3. Audio Load the CD-Audio provided with the course


materials and open the file xyz.mp3. Play the
recorded message and answer the questions in
section 2.4, page 34 of your course materials.

4. Case Study Read the following case study on “Adidas versus


Adventa” on copyright infringement. Then,
answer all the questions below. This task should
take 45 – 60 minutes.
5. Feedback Great! You have completed the exercises and
we hope you have got them right. Here is an
example of the suggested answers. If you have
most of these key words, you are alright!
Course guide 

Activities Icons Description


6. Grammar Fill in the blanks using the phrases listed in the
box. (you may use the phrases more than once):

be over call back hang up give up


put through

1. C
ould you …………….. in a moment?
I’ll check if she is around.

2. Don’t ………. on me, I will………


7. Multimedia Run the Flash file uploaded in WawasanLearn
and answer the following question…………..
Submit your answer to the tutor through your
tutorial discussion board.

8. Reading Please read ‘How monopolies make production


and pricing decisions’ from pages 318 – 325 of
your text book.

9. Reminder The description about the e-filing system in


section 2.1 that you have just read is a useful
guide for you to answer question 2b of TMA2.
Please attend to TMA2 as soon as you can.

10. Self-test Answer the following 3 questions using your


own words. Please do not look at the suggested
answers at the end of the unit until you have
completed this self test.

11. Summary It takes enormous effort and great soft skills


to placate an irate phone-in customer. You
need patience and diplomacy to reduce the
anger expressed and then to convert the irate
customer to a satisfied customer. This section
discuses some of the many strategies at your
disposal.

12. Telephone Feeback “Hi! I am Roger, your tutor for WOU333…I called
to check if you have received my email about…..
as I am still awaiting your confirmation about the
group meeting the following week”
OR
Make an effort to call your tutor within the
next two weeks and see if he/she has any new
guidance for you.

13. Tutorial Please use the following question to prepare for


your next tutorial.
“Elaborate on the FOUR major economic
activities considered essential for the New
Economic Policy to succeed within 20 years”

14. Video Load the VCD provided with the course materials
and open the file xyz.wma. Play the video and
answer the questions in section 3.8, page 53 of
your course materials.
 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Activities Icons Description


15. Vocabulary Guessing the Meaning of Words
Look at the underlined words in the passage
above. Write the number of each word beside
its synonym below. The first one has been done
for you.

16. Web Reference To know more about Malaysia’s New Economic


Policy, try browsing the Web by typing the
keywords, OR for a start, go to the following site:
http://members.tripod.com/formulapm/razak2.
html

Course organisation

Unit Title Weeks

1 Introduction to computer concepts and Java programming 2


This unit identifies problems that can be solved using computers. It
describes the basic components of a computer and the relationship
between hardware and software. It distinguishes between interpretation
and compilation, describes and gets you to use the Internet and the
World Wide Web, and describes the Java program development and
execution model. You will also install and use the Java Software
Development Kit.

2 Problem solving through objects 4


Unit 2 describes the software development cycle. It describes classes
and objects and their relationships. It ends by describing and applying
object-oriented analysis and design.

3 Classes and objects 4


This comprehensive unit describes and defines Java classes, attributes
and methods; Java identifiers; objects in Java programs; dot notation
to access the object members; names and classifies the eight Java
primitive types; differentiates among the primitive types and classes;
helps you select the most suitable primitive type for different data;
describes conversions between primitive types; teaches you how to
perform numeric calculations; describes the use of comments and their
importance; applies class packages; and differentiates among instance
members and class members.
4 Control structures 4
Unit 4 explains the order of executing program statements and guides
you in writing logical expressions. It describes different Java branching
control structures without nesting, different Java looping control
structures without nesting, and teaches you simple debugging
techniques.

5 Advance control structures and arrays 4


This unit describes nested branching structures, the effect of missing
break in switch/case statements, the effect of using break and continue
in loops, nested looping statements and why arrays are needed. It
describes simple arrays of primitive types in Java programs.

Total 18
Course guide 

Objectives

The objectives of the course are to enable the learners to:

1. Describe and state the fundamental concepts in hardware and software.

2. Analyse problems and produce software designs to handle these problems


using object-oriented programming methodology.

3. Illustrate objects construction and differentiate primitive data types and


classes and perform simple data manipulation using Java.

4. Apply the programming major components like sequence, condition and


iteration to develop applications using Java language.

5. Use arrays and apply advance control structures in the applications to


produce solution designs for problems using Java object-oriented
programming methodology.

Outcomes
The course has short-term and long-term outcomes. Immediately upon completion
of the course and its associated exercises, you would be confident to comment on
and be capable of analysing simple daily programs through the implementation of
object-oriented programming methodology. You should be capable of writing short
programs to perform routine tasks using Java.

Amongst these outcomes are:

1. To understand and state the fundamental concepts in hardware and software.

2. To explain and analyse problems and produce software designs to handle


these problems using object-oriented programming methodology.

3. To illustrate objects construction and differentiate primitive data types and


classes and perform simple data manipulation using Java.

4. To apply major components in programming like sequence, condition and


iteration to develop applications using Java.

5. To use arrays and apply advance control structures in the applications to


produce solution designs for problems using Java object-oriented
programming methodology.
10 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Continuous course assessment


This course is designed to help learners move easily from the stated objectives
through the required readings, self-tests, practice exercises and assignments to a
final examination. In assessment, you will be expected to:

1. Demonstrate comprehension of the concepts you have learnt in the course.

2. Integrate course concepts and knowledge with your own experience and
observations.

3. Apply course concepts and your own knowledge to case problems.

Assignments (the Tutor Marked Assignments, TMA) and examinations are designed
to test you and facilitate your progress. To complete the course successfully, you
are required to pass both the continuous assessment and the final examination.
Table 1.0 shows the detail suggested weekly reading and continuous corresponding
assessment.

Weeks Unit Lesson to study Tutorial Assessment


1 Unit 1: Introduction Course Guide T1
to Computer Section 1.1: Problems and
Concepts and Java computer solutions
Programming Section 1.2: Basic computer
structure

2 Section 1.3: Programming languages


Section 1.4: The Internet and the
World Wide Web

3 Section 1.5: The Java programming


language

4 Unit 2: Problem Section 2.1: The software


solving through development life cycle
objects Section 2.2: What are objects?

5 Section 2.3: Classes and objects


Section 2.4: Deriving objects from
a given problem

6 Section 2.5: Common attributes T2 TMA 1 due


and behaviours among objects

7 Unit 3: Classes and Section 3.1: Defining classes in Java


objects programs
Section 3.2: Manipulating objects

8 Section 3.3: What can Java pro-


grams manipulate?
Section 3.4: Choosing suitable
attribute types

9 Section 3.5: Manipulating data


Section 3.6: Class packages
Section 3.7: Class members
Course guide 11

Weeks Unit Lesson to study Tutorial Assessment


10 Unit 4: Control Section 4.1: Program execution order T3 TMA 2 due
structures and simple relational expressions
Section 4.2: Complex relational
expressions

11 Section 4.3: Branching or Selection


12 Section 4.4: Looping
Section 4.5: Debugging your
programs

13 Unit 5: Advance Section 5.1: Advanced branching


Control Structures statements
and Arrays Section 5.2: Advanced looping
statements

14 Section 5.3: Why are arrays needed? T4 TMA 3 due


Section 5.4: Arrays of objects

15 Overall units Specimen exam paper


16 Specimen exam paper
17 Specimen exam paper T5
18 Revision
19
20
21 Exam

Table 1.0 Suggested weekly reading and corresponding assignments

Tutor Marked Assignments (TMA)

There are three TMAs for TCC 101 Computing I. Students will complete the first
assignment about one month after commencement of the course to get a written
feedback on their initial performance. All three assignments are compulsory. They
are timed to allow for feedback from one before the next becomes due.

The assignments take the form of case studies or programming exercises. In any
case, the students need to show understanding of course concepts and apply the
concepts appropriately in the assignments. TMA 1 is worth 10% while TMA 2 and
3 is worth 20% each. All three TMAs can be found in the Appendices. Feel free to
practice doing it anytime when you are ready. The suggested weekly reading in Table
1.0 aims to guide and prepare you on the concepts and knowledge necessary in the
three TMAs. All the three TMAs are individual work and you are not allowed to
share your work with other students. Although you are encouraged to have group
discussion among your course mates, remember that the final product should be
your own individual work. Any act of collusion and plagiarism will be punished.
12 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Course delivery
Text book

There is one compulsory textbook for TCC 101 Computing I:

Malik, D S (2005) Java Programming: From Problem Solving to Program Design,


Boston: Thomson Course Technology, ISBN: 0-619-21608-5. [The ‘textbook’
indicated in the Readings of the five study units refers to this book.]

Supplementary readings

1. Shelly, G B, Cashman, T J, and Vermaat, M E (2004) Discovering


Computers 2006: A Gateway to Information. International Student Edition,
Boston: Thomson Course Technology.

2. Morelli, R (2003) Java, Java, Java!: Object-Oriented problem Solving, 2nd


edn.,Upper Saddle River, New Jersey: Prentice Hall.

3. Britton, C and Doake, J (2000) Object-Oriented Systems Development, A


gentle introduction, New York: McGrawHill.

4. Deitel/ Deitel (2003) Java How to Program, 5th edn., Upper Saddle River,
New Jersey: Prentice Hall.

5. Decker, R (2000) An Introduction to Programming Using Java/With Lab


Manual, 2nd edn., Pacific Grove, CA: Brooks/Cole.

6. Lewis, J and Loftus, W (2000) Java Software Solutions: Foundations of


Program Design, 2nd edn., Boston: Addison-Wesley Publishing.

Course material and student support


Course materials are the primary source of content that WOU provides for you to
study. They normally consist of all or some of the following:

• Study Units [developed and written by course developer(s)].

• Self-test questions and activities proposed.

• Specimen examination paper.

• Other print and non-print media that may accompany the set of course
materials.
Course guide 13

Apart from the LMS and tutorials described earlier, WOU is mindful of the need to
support you throughout the conduct of the course. Our Regional Offices are well
equipped and staffed to attend to your queries whenever they arise. We have Regional
Office Managers and tutors who are only too glad to listen to you. Whenever possible
and deemed important, the Regional Office staff will link you up with the relevant
person if need be. The Regional Offices have access to the WOU campus in Penang
and also contact with the Course Coordinator should it be required.

Learning management system

This course is supported by the Learning Management System (LMS). Students


can find course materials and the latest course information in the LMS known
as WawasanLearn. Access to the WawasanLearn is by the way of a single sign-on
password entry into the Student Portal and from there the student can ‘click’ into
the courses’ sites and associated e-forums. The students can also communicate with
their tutors, the Course Coordinator as well as fellow students.

Self help group

Advice on organising informal meetings between students completing the same


course is given in the Student Handbook. We want to emphasise the benefits of such
activities as they help to build up collegial self-help as well as to assist fellow students
in discussing the course contents. These meetings, which are purely voluntary, provide
steps for students to help one another.

Online support

http://java.sun.com/docs/books/tutorial/index.html

http://www.webreference.com/programming/java/tutorials.html

http://math.hws.edu/javanotes/

http://www.apl.jhu.edu/~hall/java/Java-Books.html#Java-Books-Tutorials2

http://oopweb.com/Java/Documents/JavaNotes/VolumeFrames.html

http://www.cafeaulait.org/course/

http://apex.vtc.com/java.php

http://chortle.ccsu.ctstateu.edu/CS151/cs151java.html
14 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Course writer’s profile


The course material for TCC 101 Computing I is prepared by Mr. Sivakumar s/o
Ramakrishnan. Mr. Sivakumar received his MSc. in Information Technology and
MSc. in Mathematics from University Sains Malaysia (USM). Currently, he is doing
his PhD in modelling Intelligent Computing in USM as well. His current research
interest include: artificial intelligence, advance logics, hermeneutic computing,
knowledge representation, cognitive science and ontology. He joined the Department
of Computer Science at Disted-Stamford College in 2001 where he is presently a
senior lecturer. He is serving as an undergraduate final year project coordinator.
Mr. Sivakumar has been teaching undergraduate courses in Object-Oriented
Design, Advanced Java, Decision Support System and Intelligent System, Discrete
Mathematics and Logic for the past five years. He has (with experience in teaching)
taught various programmes in various institutions like Unitar, Open University
Malaysia, Deakin University, Multimedia University, USM and NIIT.
Course guide 15

4.0 Tutorials – Optimising Tutorial


Sessions

T o assist you in this course, the appointed tutor will conduct five tutorials. Each
tutorial will be two hours long and will be held on weekends. Tutorials are face-
to-face sessions that enable you to exchange ideas and experiences and make contact
with others. This will benefit you.

Note: These sessions complement distance learning materials, and not replace them
in the form of lectures. In this course, the primary means of learning is through
the written word - that is, through WOU’s study materials, textbook and online
references.

Preparing for tutorials


In order to benefit fully from a tutorial, you should complete the reading and
various activities for the topics being studied. You should also prepare the answers
to the assigned case study so that you can participate meaningfully in the tutorial
discussion. Time will be allocated in the study schedule for this.

Tutors
The appointed tutors will:

• Conduct the tutorials.

• Assess the students’ assignments.

• Be available, at certain times, for consultation with the students via online
and if necessary by telephone.

Tutors are the first point of contact with the WawasanLearn for the students. If the
students need any information or have any problems, they should speak to the tutors
before contacting the Course Coordinator.
16 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Estimated study hour with TMAs

Assessment Total
Unit Self-study Hours Tutorial Hours Hours
Tutorials Time

Unit 1 15 2 TMA 1 3 20
Unit 2 20 2 TMA 2 8 30
Unit 3 20 2
TMA 3 8 52
Unit 4 20 2
Unit 5 20 2 22
Total Study Hours 124

TMA policies

The assignment policy of the University as stated in the Student Handbook should
be observed. Students are required to submit assignments for a course in accordance
with the dates communicated by the Course Coordinator. Students may apply for
a submission extension on the grounds of illness, accident, disability, bereavement
or other compassionate circumstances.

Applications for extensions of up to seven (7) days should be submitted to the tutor.
The tutor shall consider valid and unexpected emergencies on an individual basis.
Normally, documented proof of the extenuating circumstances is not required for
extensions of up to seven days. The tutor shall decide and advise you of the revised
date for submission.

For extensions of over seven days, you should note the following:

1. If students require an extension of more than seven days on the grounds


of illness, accident, disability, bereavement or other compassionate
circumstances, they are required to inform their respective tutors about
their request. The tutors will fill in the “Confirmation of extension for
assignment form” (T-EA) and submit it to the Course Coordinator.

2. Supporting documents must be submitted along with the application for


extension of over seven (7) days to justify the claim.

3. Applications for extension should normally be lodged before or on the


due date.

4. Applications are considered by:

• The Course Coordinator for extensions of 8 to 21 days.

• The Dean for extensions up to 21 days.


Course guide 17

If the assignment is posted to the tutor, it is your responsibility as a student to check


that the assignment has successfully arrived, for example, confirmation through
telephone or email. Applications for extension without supporting documents on the
grounds of postal loss will not be accepted. WOU cannot accept any responsibility for
assignments that are not received by your tutor due to problems with the post. As a
precaution, you are advised to keep a copy of each assignment you submit and obtain
a certificate of posting from the post office when you post your assignment.

According to the WOU’s policy, there is no extension of the final “TMA 3”


deadline.
18 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 19

5.0 Examination

T he final examination counts for 50% of the final course mark. It is three hours
long and consists of:

• True/False questions (10%)

• Multiple choice questions (20%)

• Short questions (40%)

• Long questions (30%)

Therefore, the overall assessment is as follow:

Type Marks

TMA 1 10%
TMA 2 20%
TMA 3 20%
Final Examination 50%
100%

Examination policies
Students must attend all required scheduled examinations that make up a final grade,
at the appointed time and place.

Individual instructors may accommodate for illness or personal crisis. Additional


accommodation will not be made unless a written request is sent to and approved
by the appropriate Dean prior to the scheduled examination.

Any student who misses a scheduled examination without approval will be awarded
“0” marks for the examination.

Passing marks
To pass the course, the students must achieve at least 40% in the continuous
assessment as well as in the final examination. Their performance in these two
components determines their total score for the whole course.
20 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Course grades table

Mark (Percent) ≥ 80 65 – 79 50 – 64 40 – 49 ≤ 39
Grade A B C D F

Assessment and examination


Assessment in the course is based on two components, which are TMA and Final
Examination. The TMA can come in a variety of modes. For example, assignment
questions can be answered at home and submitted before the due date. The CMA
is done through the WawasanLearn (where applicable). All the assessment modes fit
into three TMAs for computational and grading purposes. The final examination
will be conducted at the Regional Offices after the one week study break.

Below are the TMAs for this course:

1. TMA 1 (Appendix I)

2. TMA 2 (Appendix II)

3. TMA 3 (Appendix III)

Specimen examination questions


Please refer to Appendix IV
Course guide 21

6.0 Supporting Facilities

Y ou will need access to an IBM PC compatible computer with the following


minimum configuration:

Hardware
• Personal Computer with x86 processor (300MHz) or equivalent.

• 256MB RAM.

• Internet connection via 56K dialup modem or broadband.

Software
• Windows 98 Second Edition or newer version.

• Web Browser: Netscape 4.78 or Internet Explorer 5.0, or compatible, Firefox.

• Word Processor: Microsoft Word or WordPad. OpenOffice is available


from the Internet.

• Note: The hardware configuration above is the bare minimum. The Java
Software will be provided by WOU, or you can download it from the
official Java website.
22 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 23

7.0 A Word of Encouragement

A s this course may be the first that you have taken at Wawasan Open University
(WOU), you may not be aware of both the study skills required for distance
learning and how WOU courses are organised. It is recommended, therefore, that
you read this Course Guide thoroughly before looking at the study units or your
textbook. If you have taken WOU courses, you should be well aware of both the
study skills required for distance learning and how WOU courses are organised.
Whichever group you belong to, though, it is recommended that you read this Course
Guide thoroughly before looking at the study units or your textbook.

The Course Guide tells you briefly what the course is about and how you can work
your way through the materials. It also suggests the amount of time you will likely
need to spend in order to complete each unit (and the course), and it gives you a
general idea when your tutor-marked assignments are due.

In distance learning, as practiced by WOU, the study units are coordinated and
prepared in the distance mode of education by your university lecturer. You do not
need to attend face-to-face lectures. This is one of the great advantages of distance
learning. You can read and work through specially designed study material at your
own pace, at times and places that suit you best.

Think of it as reading the lecture notes instead of hearing it from a lecturer. In the
same way that a lecturer might set you some reading to do, the study unit tells you
when to read your textbook or other materials. In the same way that a lecturer might
give you in a class exercise, your study units has exercises (called various names) for
you to do at appropriate points. You are also likely to find review questions at the end
of each unit. Complete them, as these exercises and questions give you the practice
necessary to achieve the objectives of the course and to pass the examination. Even
when you make notes in a direct face-to-face lecture, you are advised to study those
notes and to read and think about them in relation to your textbook. In the distance
mode of education, the course materials replace the live lecture notes.
24 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 25

Appendix I

Tutor-marked
Assignment 1
(TMA 1 - 10%)
26 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 27

Tutor-marked Assignment 1
The intention of this assignment is to assess your understanding of computer concepts
and basic Java programming.

This activity is based on the material in Unit 1, and is also supported by material
in Unit 2.

The assignments in this unit have to be done individually.

Instructions:
Your assignment must be word processed (1.5 spacing) and clearly laid out. Any
additional appendices or attachments must be placed at the end of the submitted
document and must be referred to in the main body of the assignment, or it will
not be read by the marker.

Submission
You must submit hardcopy of the assessment.

All files or documents submitted must be labelled with your WOU ID and name.

Please note:

• Assignments are counted as on time if they are submitted before midnight


on the due date.

• In the case where an assignment is submitted within 10 working days


after the due date, the reason(s) for late submission should be included.
Documentary evidence may be requested. When the examiner deems the
reasons for late submission to be sufficient, the assignment will be marked
without penalty. Otherwise, when the examiner deems the reasons for
late submission to be insufficient, or no reasons are attached, the assignment
will be held and may be taken into account during the final assessment
process.

• If an assignment is not submitted or is submitted more than 10 days


after the due date, zero marks will be awarded. Any late submission of
assignment will be held and may be taken into account during the final
assessment process.

• You must keep a copy of the submitted work.

• Assignments not submitted according to the submission instructions may


not be marked.
28 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Candidates attempting to gain an unfair advantage or colluding in anyway


whatsoever (other than on joint assignments) are liable to be disqualified.
Plagiarism is an offence.

Assessment

This assignment counts 10% towards your total assessment in this course.

1. Explain the difference between a high-level programming language and


machine language.

[1.5 marks]

2. One of the components of a computer is its CPU. What is a CPU and


what role does it play in a computer?

[1.5 marks]

3. Java has become an important programming language in a very short


time. What are some of the reasons that have made it so popular? (Your
answer should include, but not be limited to, a discussion of Java’s role
on the Internet.)

[1.5 marks]

4. When you compile a Java source code file (such as Measures.java) with
the javac command, you get a class file (such as Measures.class). What
sort of information is contained in the class file?

[1.5 marks]

5. The main method of a program begins with the line

public static void main(String[] args)

What does the word “public” mean here, and why is it necessary?

[1 mark]
Course guide 29

6. a. Very briefly explain what a class is. Give an example.

[1 mark]

b. Briefly explain what an object is. Give an example.

[1 mark]

7. What is the relationship between the 16-bit Unicode character set and
the 7-bit ASCII character set? Are both supported Java characters?

[1 mark]

The End
30 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 31

Appendix II

Tutor-marked
Assignment 2
(TMA 2 - 20%)
32 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 33

Tutor-marked Assignment 2
The intention of this assignment is to give you experience in applying software
development life cycle (SDLC) using object-oriented methodology.

This activity is based on the material in Unit 2, and is also supported by material in Unit 3.

Your analysis and development of the problem should be within the domain of
given problem.

The assignments in this unit may be discussed in groups of two or three people but
the final document has to be done individually.

Instructions:
Your assignment must be word processed (1.5 spacing) and clearly laid out. Any additional
appendices or attachments must be placed at the end of the submitted document and must
be referred to in the main body of the assignment, or it will not be read by the marker.

Submission
You must submit hardcopy of the assessment.

All files or documents submitted must be labelled with your WOU ID and name.

Please note:

• Assignments are counted as on time if they are submitted before midnight


on the due date.

• In the case where an assignment is submitted within 10 working days


after the due date, the reason(s) for late submission should be included.
Documentary evidence may be requested. When the examiner deems the
reasons for late submission to be sufficient the assignment will be marked
without penalty. Otherwise, when the examiner deems the reasons for
late submission to be insufficient, or no reasons are attached, the assignment
will be held and may be taken into account during the final assessment process.

• If an assignment is not submitted or is submitted more than 10 days after


the due date, zero marks will be awarded. Any late submission of assignment
will be held and may be taken into account during the final assessment process.

• You must keep a copy of the submitted work.

• Assignments not submitted according to the submission instructions may


not be marked.
34 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Candidates attempting to gain an unfair advantage or colluding in anyway


whatsoever (other than on joint assignments) are liable to be disqualified.
Plagiarism is an offence.

Assessment

This assignment counts 20% towards your total assessment in this course.

Read the following brief description of the Just a Line car validation system.

exit:Barrier
out:Sensor

The Just a Line car park

entrance:Barrier
in:Sensor

Diagram of the car park.

Just a Line management wishes to increase security, both in their building and on
site, without antagonising their employees. They would also like to prevent people
who are not part of the company from using the Just a Line car park.

It has been decided to issue identity cards to all employees, which they are expected
to wear while on the Just a Line site. The card records the name, department and
number of the member of staff, and permit access to the Just a Line car park.

A barrier and a card reader are placed at the entrance to the car park. The driver of an
approaching car inserts his or her numbered card in the card reader, which then checks
that the card number is known to the Just a Line system. If the card is recognised, the
reader sends a signal to raise the barrier and the car is able to enter the car park.

At the exit, there is also a barrier, which is raised when a car wishes to leave the car
park. When there are no spaces in the car park a sign at the entrance displays “full”
and is only switched off when a car leaves.

Special visitor cards, which record a number and the current date, also permit access
to the car park. Visitors’ cards may be sent out in advance, or collected from the
reception. All visitors’ cards must be returned to reception when the visitor leaves
Just a Line.
Course guide 35

1. Identify possible objects and derive classes after noun, responsibility and
collaborator analysis from the Just a Line System.

a. Underline all the nouns.

b. Create Objects or classes, Class name, Remarks table.

[8 marks]

2. Identify possible attributes of classes and create attribute and class table.

[3 marks]

3. Identify possible operations on classes and draw object interaction diagram.

a. Underline all the possible operations from the passage.

b. Draw the interactions among the objects and label the operation
involved.

[5 marks]

4. Draw class diagram for the classes with data and operation.

[4 marks]

The End
36 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 37

Appendix III

Tutor-marked
Assignment 3
(TMA 3 - 20%)
38 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 39

Tutor-marked Assignment 3
The intention of this assignment is to give you experience in solving mathematics
problems and writing the code for a simple game using object-oriented methods.

This activity is based on the materials in Unit 3, Unit 4 and Unit 5.

Instructions:
Your assignment must be word processed (1.5 spacing) and clearly laid out. Any
additional appendices or attachments must be placed at the end of the submitted
document and must be referred to in the main body of the assignment, or it will
not be read by the marker.

Submission
You must submit softcopy (virus free) of the working codes and hardcopy of the
answer for assessment.

All files or documents submitted must be labelled with your WOU ID and name.

Please note:

• Assignments are counted as on time if they are submitted before midnight


on the due date.

• In the case where an assignment is submitted within 10 working days


after the due date, the reason(s) for late submission should be included.
Documentary evidence may be requested. When the examiner deems the
reasons for late submission to be sufficient the assignment will be marked
without penalty. Otherwise, when the examiner deems the reasons for
late submission to be insufficient, or no reasons are attached, the assignment
will be held and may be taken into account during the final assessment
process.

• If an assignment is not submitted or is submitted more than 10 days


after the due date, zero marks will be awarded. Any late submission of
assignment will be held and may be taken into account during the final
assessment process.

• You must keep a copy of the submitted work.

• Assignments not submitted according to the submission instructions


may not be marked.
40 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

Candidates attempting to gain an unfair advantage or colluding in anyway


whatsoever (other than on joint assignments) are liable to be disqualified.
Plagiarism is an offence.

Assessment

This assignment counts 20% towards your total assessment in this course.

1. Write a Java program for exponential raised to power of the user entered
value n (the value of Math.exp(n)). This is the base of natural logarithms
“e” raised to the power n. User only allowed to enter any integer number
between -1 and 20.

Sample output:

[4 Marks]
Course guide 41

2. When cashiers in a store return your change, they try to “fit” dollars first
into the amount you get back, then quarters (25 cent coins), dimes (10
cent coins), nickels (5 cent coins) and finally a few odd cents. For example,
let’s say that your change is 268 cents:

• Two dollar fits into 268, leaving 68 cents.

• Two quarters fit into 68 cents, leaving 18 cents.

• One dime fits into 18 cents, leaving 8 cents.

• One nickel fits into 8 cents, leaving 3 cents.

• Three cents are left.

Your change is: 2 dollars 2 quarters 1 dime 1 nickel 3 cents.

Write a program that reads change due to a user (in cents) and writes out
how many dollars, quarters, dimes, nickels, and pennies she is due. All
variables and all maths in this program will be integers. If you are stuck,
try to do an example problem with paper and pencil.

[5 Marks]

3. Consider the attached partial Turtle class below. This is a version of a


system that has been used to introduce children to programming. It
describes a world consisting of a “turtle” that moves about on a two-
dimensional surface in response to simple commands.

NORTH

WEST EAST

SOUTH
42 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I

/** An object that moves on a 2-dimensional surface, in


which x coordinates increase as one moves east, and y
coordinates increase as one moves north. At any time, the
turtle is facing north, south, east or west. */

public class Turtle {


// direction constants
public static final int NORTH = 0;
public static final int EAST = 1;
public static final int SOUTH = 2;
public static final int WEST = 3;
// fields
...
/** Create a new turtle at position (0,0),facing east. */
public Turtle() {
...
}
/** Turn 90 degrees to the right. Use modulus
(% ) for direction changes*/
public void turnRight() {
...
}
/** Move the specified number of units in the
current direction. */
public void move(int distance) {
...
}
/** The x-coordinate of the turtle’s current position. */
public int getX() { ... }
/** The y-coordinate of the turtle’s current position. */
public int getY() { ... }
}

a. Fill in the missing parts of the class.

[4 marks]

b. Without changing the Turtle class, write an additional method


distanceTravelled() which will calculate the total distance traveled by
this turtle and return the total distance value. Make sure you are
adding total distance data in other method if necessary.

/** The total distance traveled by this turtle. */


public int distanceTravelled() { }

[2 marks]
Course guide 43

c. Write TurtleTester class program to initialise the Turtle class and


print some possible move, direction and tuning of a Turtle object.

For example:

[5 marks]

The End
44 WAWASAN OPEN UNIVERSITY
TCC 101 Computing I
Course guide 45

Appendix IV

Specimen Examination
Questions
(Time: 3 Hours)
.../-
Specimen Copy

Academic Session 2007


First Semester Examination
May/June 2007

TCC101
Computing 1
Time: 3 Hours

Instructions to candidates:

1. Please check that this examination paper consists of Fourteen (14) printed
pages before you begin the examination.

2. Write in black or blue pen in the answer booklet provided.

3. This paper consists of 4 parts: Part A (10 questions), Part B (20 questions)
and Part C (5 questions) and Part D (4 questions).

4. Answer all questions in Part A, B and C, and three out of four in Part D.

5. No books, dictionaries, notes or any unauthorised materials are allowed


into the examination venue.

6. Non-programmable electronic calculator may be used.

.../-
2

Part A

True and False Questions


(10 marks)

Please indicate T for True answer and F for False answer in your answer
booklet provided.

Questions T/F
1. Primary storage is sometimes known as the peripheral
equipment of the computer.
2. COBOL is an example of a 1st generation language.
3. All third generation languages are only able to compile.
4. In creating a program you need to frequently revise the source
file, compile new bytecodes, and run the program to see the
result. This process is called the edit, compile and run cycle.
5. Say that your program was compiled without problems, but
when you run it something goes wrong. This is called a bug.
6. An application is a Java bytecode program that runs by help
of a web browser.
7. To convert a string of characters to a double, use the parseDouble()
method of wrapper class Double.
8. When a mechanical machine repeatedly does something in
performing its work it contains a cycle. When a program
repeatedly executes the same statements, it contains a loop.
9. The three things must be coordinated in order for a loop to
run correctly.
a. The initial values must be set up correctly.
b. The condition in the while statement must be correct.
c. The change in variable in the loop body must be correct.
10. A parameter is an item of data supplied to a method when the
method is invoked.

.../-
3

Part B

Multiple Choice Questions


(20 marks)

Answer all questions in the answer booklet provided.

1. What hardware components (of a typical desktop computer) are usually


found inside the systems unit?

A. The processor, main memory, and monitor.


B. The processor, main memory, and secondary memory.
C. First, second, and third memory.
D. The keyboard, the disks, and the audio blaster.

2. What does the word binary mean?

A. Binary means “containing a computer.”


B. Binary means “having only two states.”
C. Binary means “having a discrete number of values.”
D. Binary means “using electronics to do arithmetic.”

3. What is a group of 8 bits usually called?

A. A bite.
B. A bight.
C. A byte.
D. A blight.

4. What is a source program?

A. The program that the processor is executing a particular instant.


B. The first copy ever made of a program.
C. A text file created by a programmer containing instructions written in a
high level language.
D. A collection of machine instructions that the processor can execute.

5. What is a data type?

A. The part of the CPU that does arithmetic.


B. A part of main memory used to store data.
C. A particular scheme for representing values with bit patterns.
D. The collection of variables that a program uses.

.../-
4

6. What is a Java primitive data type?

A. A method for representing values that is so useful that it is a fundamental


part of the language.
B. A crude form of representing numbers.
C. The part of Java that is the same as in older languages.
D. A data type that cannot be used as part of an object.

7. Which one of the following is a reserved word?

A. apple
B. 7up
C. grandTotal
D. boolean

8. Which of the following expressions is incorrect?

A. (34 - 86) / 3
B. (34 - 86) / -3
C. 34 - 86) / (23 - 3)
D. ( (34 - 86) / (23 + 3) )

9. What does the following program output?

class question4{
public static void main ( String[] args ) {
int totalCost = 6;
int items = 12;
System.out.println(“cost per item:” + totalCost/items);
}
}

A. cost per item: .5


B. cost per item: 0
C. cost per item: 1
D. cost per item: +6/12

10. What is the value of -32 % 6

A. 5
B. -5
C. 2
D. -2

.../-
5

11. What does the following code fragment write to the monitor?

int sum = 14;


if ( sum < 20 )
System.out.print(“Under “);
else
{
System.out.print(“Over “);
System.out.println(“the limit.”);
}

(Notice that the program has changed from the previous question!)

A. Under
B. Over
C. Under the limit.
D. Over the limit.

12. What does the following code fragment write to the monitor?

int sum = 7;
if ( sum > 20 ){
System.out.print(“You win “);
}
else{
System.out.print(“You lose “);
}
System.out.println(“the prize.”);

(Notice that the program has changed from the previous question!)

A. You win
B. You lose
C. You win the prize
D. You lose the prize

13. Evaluate (to true or false) each of the following expressions:

14 <= 14 14 < 14 -9 > -25 -25 > -9

A. true true true true


B. true false false false
C. true false true true
D. true false true false

.../-
6

14. What makes a loop a counting loop?

A. A loop control variable is tested in the while statement, and is changed


each time the loop body executes.
B. A counter is counted upwards by one until it hits a particular limit.
C. A counter is counted downwards by one until it hits zero.
D. No loop control variables are used.

15. What attributes do all real-world objects have?

A. Objects have identity, state, and behaviour.


B. Objects have state and behavior.
C. Objects have size and weight.
D. Objects have existence.

16. Examine the following section of code:

String strA;
String strB = new String(“Cheese”);

How many objects have been created?

A. zero
B. one
C. two
D. three

17. Why is the main() method special in a Java program?

A. It is where the Java interpreter starts the whole program running.


B. Only the main() method may create objects.
C. Every class must have a main() method.
D. The main() method must be the only static method in a program.

.../-
7

18. Here is the general syntax for method definition:

accessModifier returnType methodName( parameterList ){


Java statements
return returnValue;
}

What is true for the accessModifier?

A. It must always be private or public.


B. It can be omitted, but if not omitted it must be private or public.
C. It can be omitted, but if not omitted there are several choices, including
private and public .
D. The access modifier must agree with the type of the return value.

19. What access modifier explicitly says that a method or variable of an object
can be accessed by code outside of the object?

A. private
B. public
C. default
D. static

20. What is the output of the following code fragment?

for ( int j = 10; j > 5; j-- )


{
System.out.print( j + “ “ );
}
System.out.println( );

A. 10 11 12 13 14 15
B. 9 8 7 6 5 4 3 2 1 0
C. 10 9 8 7 6 5
D. 10 9 8 7 6

.../-
8

Part C

Short Questions
(40 marks)

Answer all questions in the answer booklet provided.

1. a. Define the term:

i. Compiler

ii. Class

iii. Attributes of real world objects

iv. Static method (also called as “static subroutine”).

v. Pseudocode

[5 marks]

b. One of the two major components of a computer is the RAM. What is


the function of the RAM?

[2 marks]

c. What is the relationship between classes and objects?

[4 marks]

2. a. Explain what the term “static” means when used as a modifier on a


variable or method declaration in a class.

[3 marks]

b. Write the method header (or signature) for a public class method that
takes as parameters an integer and a String and returns a boolean.
(Note that you DO NOT need to write any code for the class, only give
its header)

[3 marks]

.../-
9

c. What is the effect of giving a class member private access?

[3 marks]

3. a. Circle the syntax errors in the following code, and state briefly what is
wrong in each case:

int ct;
ct = 0;
while ct < 10 {
ct++;
if (ct % 2 = 0)
System.out.println(ct);
}

[3 marks]

b. What are the possible values expression?

(int)(2 + 4*Math.random())

[3 marks]

4. a. The following program is supposed to write out the integers 1, 2, 3, and


4. Decide what should go in the blanks.

class Counter {
public static void main (String[] args) {
int count ;
count =_______ ;

while ( count____ 4 ) {
System.out.println( count );
count = count + ___ ;
}
}
}

[1.5 mark]

...10/-
10

b. The following program is supposed to write out the integers 10, 11, 12,
13, 14, and 15. Decide what should go in the blanks.

class Counter2 {
public static void main (String[] args) {
int j ;
j = ____ ;
while ( j <_____ ) {
System.out.println( j );
j = j + ______ ;
}
}
}

[1.5 marks]

c. The following program is supposed to write out the values 1!, 2!, 3!, 4!,
up to 10!. Fill in the blanks.

class Factorial {
public static void main (String[] args) {
int fact =___ ; // current factorial value
int count = ___ ;// loop control
while ( count __ 10 ) {
fact = fact *_______ ;
System.out.println( count +”! is “ + fact );
count = count + 1 ;
}
}
}

[2 marks]

5. a. Examine the following code:

int count = -2 ;
while ( count < 3 ) {
System.out.print( count + “ “ );
count = count + 1;
}
System.out.println( );

What does this code print on the monitor?

[3 marks]

...11/-
11

b. What is written to the monitor by the following section of code:

String strA = new String(“Roasted “);


String strB = new String(“Acorns “);
strA = strB;
if ( strA == strB )
System.out.println(“Two copies of a reference.”);
else
System.out.println(“Two different references.”);

[3 marks]

c. Convert the while loop into for loop:

int x = 0;
while ( x < 500 ){
System.out.println( x );
x = x + 5;
}

[3 marks]

...12/-
12

Part D

Long Questions
(30 marks)

Answer 3 questions out of the 4 questions given in the provided answer


booklet.

1. a. Draw a flowchart that sums up an unknown number of positive integers,


and then prints the total. Use an appropriate sentinel value.

[5 marks]

b. If F is a temperature measurement in degrees Fahrenheit, then the


same temperature in degrees Celsius would be 5*(F-32)/9. Write a Java
method that converts Fahrenheit to Celsius, where the Fahrenheit
temperature is a parameter and the Celsius temperature is the return
value.

[5 marks]

2. Read the following brief description of the Bank Transfer System.

“The bank system transfers an amount of money from a source account to


a destination account. It first withdraws the amount from the source
account and then deposits the same amount in the destination account.”

a. Identify possible objects and derive classes after noun, responsibility


and collaborator analysis from the Bank System.

i. Underline all the nouns.

ii. Create Objects or classes, Class name, Remarks table.

b. Identify possible attributes of classes and create attribute and class table.

c. Identify possible operations on classes and draw object interaction


diagram.

i. Underline all the possible operations from the passage.

ii. Draw the interactions among the objects and label the operation
involved.
...13/-
13

d. Draw class diagram for the classes with data and operation.

[10 marks]

3. a. Write a complete class definition for a class named Player that meets
the following specifications: An object of type Player represents a player
in a game. The object has private instance variables to represent the
player’s name and score. There is one constructor, with a parameter
that specifies the player’s name. (The player’s score is initially zero.)
The class defines methods for getting the player’s name and score and
for adding a specified number of points to the score.

[5 marks]

b. Write a function

public static double minimum(double array[])

that returns the smallest of all the numbers in the array. You may assume
that the array is non-empty.

[5 marks]

4. Implement the following class into Java codes. The attributes must have
types (int, String and double in this case). You have to write a complete
program without main() method and you are not required to initialise the
class. You should define the class and declare the data variables and
contents for the methods with return statement if required.

Given:

The three most important numbers describing a telescope are: 1) the


diameter of the main lens (the one in front), 2) the focal length of the main
lens, and 3) the focal length of the eyepiece. From these values other
characteristics of the telescope such as its magnification and the f-number
of the main lens are calculated.

The formula to use is: magnification = mainLength/eyeLength


The formula to use is: fNumber = mainLength/diameter

...14/-
14

Telescope
diameter: double
mainLength: double
eyeLength: double

getDiameter(double dmeter): void


getMainLength(double mLength):void
getEyeLength(double eLength):void
magnification():double
fNumber():double

[10 marks ]

End of question paper

...15/-
...16/-

You might also like