Laboratory 0 2-0 4: Requirements
Laboratory 0 2-0 4: Requirements
Cluj Napoca
Faculty of Mathematics and Computer Science
Fundamentals of Programming
LABORATORY 02-04
REQUIREMENTS
Deadline – you have one week to complete each iteration. The grade deduction is then 1p/week
for each remaining iteration. Deduction for delays will be of maximum 5p.
Babeș-Bolyai University
Cluj Napoca
Faculty of Mathematics and Computer Science
Fundamentals of Programming
1. NUMERICAL LISTS
A math teacher needs a program in order to help students to test different properties of numbers.
The program manages a list of numbers and also allows students to repeatedly execute the following
functionalities (each functionality is exemplified):
prime from 1 to 5 – writes the prime numbers between position 1 and 5 in the list.
odd from 1 to 5 – writes the odd numbers between position 1 and 5 in the list.
sum from 1 to 5 – writes the sum numbers between position 1 and 5 in the list.
gcd from 1 to 5 - writes the greatest common divisor of elements between position 1 and 5 in
the list.
max from 1 to 5 – writes the greater element of the sublist from position 1 to 5.
5. Filter.
undo – the last operation that has modified the list of numbers is cancelled.
Babeș-Bolyai University
Cluj Napoca
Faculty of Mathematics and Computer Science
Fundamentals of Programming
2. CONTEST
At a programming contest, after evaluating the existing solutions, the evaluation committee has
recorded into a list the scores obtained by the participants (at position i into the list is the score of the
i-th participant). Knowing that the participants had to solve 10 problems, each problem evaluated
with maximum 10 points, write a program in order to help the committee to repeatedly execute the
following functionalities (each functionality is exemplified):
less than 40 – writes the participants having the score less than 40.
sorted – writes the participants sorted in a certain order, considering their scores
sorted and greater than 90 - writes the participants having the score greater than 40.
avg from 1 to 5 – writes the average of the scores for the participants between position 1 and
5 in the list.
min from 1 to 5 - writes the lowest score of the participants between position 1 and 5 in the
list.
mul 10 from 1 to 5 – writes the scores multiple of 10 of the participants between position 1
and 5 in the list.
5. Filter scores.
filter mul 10 – retains only the participants that have the score multiple of 10 (which have
completely completed several/all problems).
filter greater than 70 –retains only the participants having scores greater than 70.
undo – the last operation that has modified the list of scores is cancelled.
Babeș-Bolyai University
Cluj Napoca
Faculty of Mathematics and Computer Science
Fundamentals of Programming
A family wants to manage its monthly expenses. In order to complete this task, the family needs an
application to store, for a certain month, all the family’s expenses. Each expense will be stored in the
application through the following elements: day (of the month in which it was made), amount of
money and the type of the expense (one of: housekeeping, food, transport, clothing, telephone &
internet, others – books, films, sports, etc). The family needs an application in order to repeatedly
execute the following functionalities (each functionality is exemplified):
add 10, others – adds to the current day an expense of 10 RON for books
insert 25, 100, food – inserts in day 25 an expense of 100 RON for food.
5. Filter.
undo – the last operation that has modified the list of expenses is cancelled.
Babeș-Bolyai University
Cluj Napoca
Faculty of Mathematics and Computer Science
Fundamentals of Programming
John wants to manage his bank account. In order to complete this task, John needs an application to
store, for a certain month, all the banking transactions which were performed on his account. Each
transaction will be stored in the application through the following elements: day (of the month in
which the transaction was made), amount of money transferred into/from the account, the type of the
transaction (into the account – in or from the account - out), and description of the transaction. Please
help John to create an application in order to repeatedly execute the following functionalities (each
functionality is exemplified):
add 100, out , description – adds to the current day an out transaction of 100 RON with the
given description
insert 25, 100, in, description – inserts in day 25 an in transaction of 100 RON with the given
description
5. Filter.
undo – the last operation that has modified the list of transactions is cancelled.
Babeș-Bolyai University
Cluj Napoca
Faculty of Mathematics and Computer Science
Fundamentals of Programming
Michael is the administrator of an apartment building and wants to manage the monthly expenses
for each apartment in the building. In order to complete this task, Michael needs an application to
store, for a certain month, the expenses for each apartment. Each expense will be stored in the
application through the following elements: amount, type of the expense (the administrator wants to
group the expenses in several predefined categories: such as water, heating, illuminating, gas, others).
Michael needs an application in order to repeatedly execute the following functionalities (each
functionality is exemplified):
insert 100, type at 25 – inserts at apartment 25 an expense of 100 RON having the given type
greater than 100 - writes all the apartments with an overall expense greater than 100 RON
less than 100 before 15 - writes all the apartments with an overall expense less than 100 for
apartments from 1 to 15
all type – writes all the expenses having the specified type.
balance 10 – computes the balance (total amount) for apartment 10
sum type – writes the total amount for the expenses having the specified type.
max 25 – writes the maximum expense per type for apartment 25
asc sort apt – sorts the total expenses/apartment in an ascending order
desc sort type - sorts the total expenses per type in a descending order
5. Filter.
filter type – retains only the expenses having the specified type.
filter 300 – retains only the overall expenses greater than 300 RON
undo – the last operation that has modified the list of expenses is cancelled.