IT320 Midterm 2019

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

University year Exams ‫امتحـــانـــات السنة الجــــامعيّة‬

2018/2019 2019/2018

Object Oriented Programming (IT320)


Midterm Exam
April 11, 2019

Name …………………………………………………………………... Student ID …………………………………………

Reminders
• Time : 120 minutes (2 hours)

• This is a close-book exam. You are not allowed to use your own papers, documents, scripts,
websites etc.,
• You have to use the computers inside the laboratory, unless your teacher authorizes you to
use your own computer.
• At the end, you have to upload your project (zipped) at the e-learning platform
e-learning.tbs.rnu.tn under midterm1

Exercise 1:

A local bank in your town is looking for someone to write a program that calculates a customer’s
checking account balance at the end of each month. The data is stored in a file in the following
form:

467343 23750.40

W 250.00

D 1200

W 75.00

1
The first line of data shows the account number, followed by the account balance at the
beginning of the month. Thereafter each line has two entities: the transaction code and the
transaction amount. The transaction code W or w means withdrawal, and D or d means deposit.
The program updates the balance after each transaction. If after anytime the balance goes below
$1000.00, a $25 service fee is charged. The program prints the following information: account
number, balance at the beginning of the month, balance at the end of the month, total amount
of deposit, number of deposits, total amount of withdrawal, number of withdrawals, and service
charge of any.

Input: a file consisting of data in the above format.

Output: the output is of the following form:

Account number: 467343

Beginning Balance: $23750.40

Ending Balance: $24245.25

Amount Deposited: $2230.50

Number of Deposits: 3

Amount withdrawn: $1735.65

Number of Withdrawals: 6

Note that the output to be sent to a file.

Helpful Script:

Reading/writing from/to File:

• Scanner inFile = new Scanner(new FileReader(“FileName.txt”));

• PrintWriter outFile = new PrintWriter (“outputFile.txt”);

2
Exercise 2:

Given a matrix M having the size 5x5. The user is asked to enter the values to fill the matrix, only
positive values are accepted. After filling the matrix, the program displays a menu with the following
operations:

1. Find and output the digit having the maximum number of occurrences

Example

23 453 63 33 86
The digit having the maximum
1 37 25 34 98
number of occurrences is 3
4 0 98 1 993

43 3341 46 23 33

43 67 83 37 33

2. Replace all the duplicated numbers with zero so that each number appears only once (except
if M[i][j] is equal to zero).
Example: the result of the previous matrix should be

0 453 63 0 86

0 37 25 34 98

4 0 98 0 993

0 3341 46 0 0

0 67 83 37 0

You might also like