This page contains all of the weekly homework tasks that are to be presented in class.
Please note, that some upcoming homework tasks may be added, updated or removed during the semester as the course progresses, however no updates will be made to tasks that are due in less than a week (i.e. homework for week 4 will not change after the class has been held for week 3)
Due week 2
Task 1: Go through the Getting started. Complete all the task set out on the page.
Task 2: Solve the task about average wage in Estonia.
For this task, you need to create a C program code [W02-4] and a directly matching algorithm as a UML activity diagram [W02-5].
Requirements for the solution:
- User is asked for the start and end times of work
- User is asked for number of days they worked during a month
- User is asked for the hourly wage
- Calculate and print
- How much does the employee make in a day
- How much does the employee make in a month
- Print if this is above, below or equal to Estonian average gross income. Use the number for the most recent published monthly wage. (e.g. june 2025)
https://www.stat.ee/en/find-statistics/statistics-theme/work-life/wages-and-salaries-and-labour-costs/average-monthly-gross-wages-and-salaries
Example
- Start at 9, end at 16, hourly wage 11, days in a month 21.
- Results: Daily income 77, monthly income 1617.
- This is lower than the average gross income in Estonia!
Some helpful materials: Introduction to algorithms and UML
Due week 3
Task: Continued development of the food scale program [W03-5]
Use your second week’s second class assignment, in which you created the food scale application, as the base for this task.
Add the following functionality to the application
- The allowed weighing range of the scale is 0 – 50 kg
- The measurement uncertainty of the scale is ±10 grams plus 1% of the reading (mass)
- For example, if the scale shows a mass of 2.00 kg, the actual mass may range from 1.97 to 2.03 kg
- The menu must have two levels
- From the first-level menu, the user selects a product category (e.g., fruits, vegetables). You must have at least 3 categories.
- From the second-level menu, the user selects a product within the chosen category. Each category must have at least 3 products.
- The price offered to the user must take into account the entire measurement uncertainty in favor of the user – i.e., not charging for it. For example, if the scale shows a mass of 2.00 kg, the user may only be charged for 1.97 kg.
- Error messages must be clear and correspond to the actual error that occurred. The application must be able to detect the following
- No product on the scale (taking measurement uncertainty into account in both directions – e.g. if the scale weight is -5 grams or +2 grams, they both would mean no product on the scale)
- Faulty scale reading (e.g., weighing plate lifted)
- Overload (above the certified measuring range)
- Unknown product category
- Product missing from the selected category / unknown product
The solution will be defended in class. Make sure to have the source code ready to be presented.
Due week 4
Homework: Model the algorithm of third week’s second lab task (cashier with input validation) as an activity diagram.
The solution must be logically identical to your code.
Some key aspects and hints
- To model loops, you must model all the elements of the loop
- This includes the initial values, loop condition, loop body etc – depending on what the loop needs
- You must also pay attention to the differences of entry and exit control
- If the loop also contained an if statement, you need to model it as such – you will end up with two conditions, the outside one being the loop condition and the inside one being the conditional statement. Make sure to have them in the right order and location. You cannot combine them into one.
-
break statements are not modeled as an action! Instead, break statements are just the change of the control flow – point it at where the program would continue execution.
Thought process: nothing is being done when a break occurs, instead the program proceeds to complete the next statement after the loop. - Don’t forget the merge nodes. If you have two flows merging, you need a merge node.
- If you only have one entering flow and one exiting flow, then a merge node is not usued.
- Algorithms are programming language agnostic. You need to specify the sequence of actions, not 1:1 copy the statements from the program code
- E.g. you shouldn’t used statements from the C language, such as printf, scanf. Also keywords like while, do .. while, for should be avoided.
- When modelling conditional statements and mathematical operations, it can be helpful to both write the expression alongside the text. E.g.
- Initializing the PIN attempt counter to 3, i.e. pinAttemptsLeft = 3
- Incrementing the PIN tries counter by 1, i.e. i++
Some additional ideas can be found from a slightly more complex algorithm example: UML example: filtering positive numbers into an array.
Solution is defended in the class. Make sure to have access to both the diagram as an exported image and the project file.
Due week 5
There is no homework assignment for this week. Make sure that all your labs are done and defended. If you have any tasks still to do from the previous classes, make sure to work on them.
Due week 6
Write a program based on the task description: Age classifier
Due week 7
- Take the provided code here: post.c
- The code is based on Algorithm 5: package ratios.
- Translate the algorithm from the code to UML in its entirety.
- Each statement must have a worded out explanation what is being done or checked! Copy-pasting statements from code is considered is not sufficient (e.g. having an action just be minInd = i does not explain what is being done!)
- Details such as how many places after the comma to display or where to put a newline are not shown in the algorithm!