Sunteți pe pagina 1din 3

UNIVERSITY OF ZIMBABWE

Department: COMPUTER SCIENCE


Paper code and Title: HCT 216 PROGRAMMING II
Duration Three (3) HOURS
1.

INSTRUCTIONS
This paper has One Question with sub-questions
2. Answer ALL Questions

3. This paper comprises FOUR (4) Printed pages.


Submission Requirements:
Promptly at the end of this practical examination Java files consisting your solution to each of the examination
questions in turn will be copied from your solution directory on the network drive to an empty assessment directory,
compiled, run and results evaluated. This procedure will be automated so its very important for your submission to
conform precisely to the following requirements.
In the root of your home directory on the network drive you need to create a directory named after your registration
number. Note this directory name is specified in lowercase for example:
hct216test15
Inside this directory you need to create a directory named after the practical examination. This directory must be
named r0120219. Note this directory name is specified in lowercase for example:
hct216test15\r0120219
Save your solutions in this directory. Dont create any subfolders in this directory.

Page 1 of 3

Read the following case study and answer questions that follow.
The director for psychomotor activities at the University of Zimbabwe is interested in having a Java application that automates
all sporting activities their members participate in. Each member is identified by a fullname, department, joining date, account
and sporting activity. Each sporting activity has a name and coordinator. An account is modelled as a dynamic collection of
payment details (date of payment and amount paid). There are two types of members namely students and members of staff.
Students are identified by a registration number and members of staff are identified by an EC# number. Each member pays a
once-off joining fee of $100.00 and annual subscriptions of $10.00 which must be paid on or before every 365.25 days from the
joining date. If the member does not pay the full subscription on time they are charged interest of 1% per annum compounded
monthly on the balance of the subscription fee. Interest is not charged on joining fee. Members are refunded 30% of the
joining fee when they quit provided that they paid the full amount at the joining stage otherwise they dont get refunded. Before
they get this refund all outstanding subscriptions should be deducted and if they still owe the some money then the must pay
the balance in cash. The total balance due is calculated as follows:
As an example to calculate interest for 19 days on an outstanding subscription of $6.60 = 6.60*(1 + 0.01/12) (19/365)*12)
The formula for annual compound interest is A = P (1 + r/n) nt
Where:
A = total subscription fees including interest
P = outstanding subscription balance
r = the annual interest rate (decimal)
n = the number of times that interest is compounded per year
t = the number of years the subscription fee is overdue

Required:
a) Draw a class diagram which model the above operations.
[10 marks]
b) Implement all classes which are required to automate operations. Your classes should include the necessary state and
behavior. The behavior should include constructors.
[12 Marks]
c) Implement methods which perform the operations below. The methods must be placed in appropriate classes.
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.

ix.

Register a member (entails creating a member object saving it to an output file called members.txt). Name your
method register
[9 marks]
Print details of a member to the console screen. Name your method print
[6 marks]
Compare two members for equality. Name your method equals
[6 marks]
Read details of a member through the keyboard. Name your method read
[9 marks]
Clone a member (name your method clone),
[6 marks]
Calculate the outstanding balance of a member who has not yet quit. Call your method liveBalance.[10 marks]
Calculate the outstanding balance of a member who has quit. Call your method terminalBalance. [10 marks]
Print to an output file a statement for a member who has not yet quit. The statement should be nicely formatted
and should show all the details of a member and all their transactions. The method should be called fileprint and
the output file should be named after the name of a member but with no spaces and as a text file (with a .txt extension)
[15 marks]
Archive a member (entails recording the details of a member in a database-in the correct relation-you should
create a database called members and then have a table to store records about each type of members-only
Page 2 of 3

concreate classes should have relations in your database and they should use attributes specified in the case
study) Name your method archive.
[20 marks]
Create a class called MemberTest with the main method and create objects in Table 1 by calling your read method. Immediately
after creating each object, call your print, register, liveBalance, terminalBalance and fileprint methods respectively.

Table 1: Members
Type of
member

Fullname

Dept Joining
Date

Account

Student

Kurauone
Daindakaziva

CS

-paid $80.00 of the joining fee on 21- Plays soccer and Nestai
r002019x
10-2012
Muroiwa is the coordinator
- paid a subscription of $4.50 on 23-82013 and a subscription fee of 12.50 on
13-10-2014

Staff

Tofirei
Kufakunesu

MTH 13-112011

21-102012

Sporting activity

Reg#/EC#

-paid $100.00 of the joining fee on 13- Plays tennis and Dambudzo 84946
11-2011
Munondiitei is the
- paid a subscription of $10.00 on 13- coordinator
12-2012 and a subscription fee of 12.50
on 11-11- 2013

d) In the class called MemberTest that you created in part d), define an array and store the objects that you created in part
d) and use a looping construct to iterate through the collection while archiving the details of the objects using your archive method.
[5 Marks]
e) In the class called MemberTest that you created in part d), write code which performs the following queries and then send
the results to an output file called database.txt:
i. List the total number of members who joined in 2011.
[ 8 marks]
ii. List all members who have not paid the joining fee in full
[8 marks]
End of Examination

Page 3 of 3

S-ar putea să vă placă și