Вы находитесь на странице: 1из 4

UNIVERSITI MALAYSIA SABAH

SCHOOL OF ENGINEERING AND INFORMATION TECHNOLOGY

Course Details

Code : KK30303
Name : Programming Languages
Lecturer : Dr. Jason Teo (SKTM, Block A, 1st Floor, Deputy Dean’s Room)

Note: Please remember to submit your assignment typed out and


submitted as per the format outlined in the course supplementary
handout given to you on the first day of lecture. Please also adhere strictly
to the deadline set for submission of your assignment, otherwise a penalty
of 1 mark will be incurred for each day the assignment is late.

Assignment 2 – Program Coding Comparison between Imperative and


Object-Oriented Proramming
(100 marks representing 20% of your final course grade)

Based on your first assignment, you should now have a good idea of how an imperative
language differs from an object-oriented language in terms of its programming
paradigm and constructs. In this second assignment, you are now required to program a
simple application using an imperative language as well as an object-oriented language
that are both new to you. The objective of this assignment is to teach you how to learn
and program in a new language on your own based on your understanding of the
features and paradigm of the programming language. A list of free
compilers/interpreters can be found at:
http://www.thefreecountry.com/compilers/index.shtml

IMPORTANT!!

Your final submission must include:

1. your source codes and executable programs in one CD-R placed in separate
directories named Question1 and Question2 for each of the questions;

2. a hardcopy printout of your source codes and screenshots of your final outputs.

3. remember, as in assignment 1, you are not allowed to use the following


languages: C, C++, C#, JAVA, AND BASIC/VISUAL BASIC.
Question 1

Using an imperative language of your choice, implement a simple application based on a


structured programming methodology.

a) State the name of your chosen language, the reasons why you chose this
particular language and list down the link from where you downloaded the
compiler/interpreter.
(10 marks)

b) Design the data structures and required functions to implement a bank account.
The entity “Account” must have a balance of the amount of money in the bank
account, functions to deposit and withdraw money, and a function to query the
current balance.
(10 marks)

c) Based on the bank account created in (a), design the data structures and required
functions to have a higher-level entity called “bank” which uses the bank account
created earlier. This “bank” must have two different bank account types, checking
(C) and savings (S), based on the “Account” that is described above.
(10 marks)

d) Next, implement four functions for the “Bank” entity for depositing, withdrawing,
and transferring money as well as printing out to screen the balance of the
amount of money in the related account.
(10 marks)

For the deposit or withdrawal, it indicates which account is affected. For a transfer, it
indicates the account from which the money is taken; the money is automatically
transferred to the other account.

Test your program using the following transactions.

1. Deposit $7500 to checking


2. Deposit $4500 to savings
3. Withdraw $2000 from savings
4. Transfer $2500 from checking to savings
5. Print out to screen the balance of both checking and savings accounts
(10 marks)
Question 2

Now using an object-oriented language of your choice, implement the same simple
application as in Question 1 but now based on an object-oriented programming
methodology. The instructions that follow are similar to the ones stated in (a) and have
been included for your easy reference and understanding.

a) State the name of your chosen language, the reasons why you chose this
particular language and list down the link from where you downloaded the
compiler/interpreter.
(10 marks)

b) Design the class and required methods to implement a bank account. The object
“Account” must have a balance of the amount of money in the bank account,
functions to deposit and withdraw money, and a function to query the current
balance.
(10 marks)

c) Based on the bank account created in (a), design the data structures and required
methods to have a higher-level object called “Bank” which uses the bank account
created earlier. This “Bank” must have two different bank account types, checking
(C) and savings (S), based on the “Account” that is described above.
(10 marks)

d) Next, implement four methods for the “Bank” entity for depositing, withdrawing,
and transferring money as well as printing out to screen the balance of the
amount of money in the related account.
(10 marks)

For the deposit or withdrawal, it indicates which account is affected. For a transfer, it
indicates the account from which the money is taken; the money is automatically
transferred to the other account.

1. Deposit $7500 to checking


2. Deposit $4500 to savings
3. Withdraw $2000 from savings
4. Transfer $2500 from checking to savings
5. Print out to screen the balance of both checking and savings accounts
(10 marks)

(Total: 100 marks)


ENSURE THAT YOUR CD-R IS SCANNED FOR VIRUSES BEFORE
SUBMISSION TO ENSURE THEY ARE VIRUS-FREE. VIRUS-INFECTED CD-
RS WILL IMMEDIATELY ATTRACT A ZERO FOR THE PROGRAMMING
COMPONENT OF YOUR TOTAL MARK.

Вам также может понравиться