{"id":10290,"date":"2025-07-15T18:20:01","date_gmt":"2025-07-15T16:20:01","guid":{"rendered":"https:\/\/blue.pri.ee\/ttu\/?page_id=10290"},"modified":"2025-11-21T13:23:22","modified_gmt":"2025-11-21T11:23:22","slug":"weekly-homework","status":"publish","type":"page","link":"https:\/\/blue.pri.ee\/ttu\/programming-i\/weekly-homework\/","title":{"rendered":"Weekly homework"},"content":{"rendered":"<p>This page contains all of the weekly homework tasks that are to be presented in class.<\/p>\n<p>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\u00a0 week (i.e. homework for week 4 will not change after the class has been held for week 3)<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/weekly-homework\/#Due_week_2\" >Due week 2<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/weekly-homework\/#Due_week_3\" >Due week 3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/weekly-homework\/#Due_week_4\" >Due week 4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/weekly-homework\/#Due_week_5\" >Due week 5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/weekly-homework\/#Due_week_6\" >Due week 6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/weekly-homework\/#Due_week_7\" >Due week 7<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Due_week_2\"><\/span>Due week 2<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>Task 1:<\/strong> Go through the <strong><a href=\"https:\/\/blue.pri.ee\/ttu\/resources\/getting-started\/\">Getting started<\/a>. <\/strong>Complete all the task set out on the page.<\/p>\n<p><strong>Task 2: <\/strong>Solve the task about average wage in Estonia.<\/p>\n<p>For this task, you need to create a <strong>C program code [W02-4]<\/strong> and a directly matching algorithm as a <strong>UML activity diagram [W02-5]<\/strong>.<\/p>\n<p>Requirements for the solution:<\/p>\n<ul>\n<li>User is asked for the start and end times of work<\/li>\n<li>User is asked for number of days they worked during a month<\/li>\n<li>User is asked for the hourly wage<\/li>\n<li><strong>Ca<\/strong>lculate and print\n<ul>\n<li>How much does the employee make in a day<\/li>\n<li>How much does the employee make in a month<\/li>\n<\/ul>\n<\/li>\n<li>Print if this is <strong>above<\/strong>, <strong>below<\/strong> or <strong>equal<\/strong> to Estonian average gross income. Use the number for the most recent published monthly wage. (e.g. june 2025)<br \/>\n<strong><a href=\"https:\/\/www.stat.ee\/en\/find-statistics\/statistics-theme\/work-life\/wages-and-salaries-and-labour-costs\/average-monthly-gross-wages-and-salaries\">https:\/\/www.stat.ee\/en\/find-statistics\/statistics-theme\/work-life\/wages-and-salaries-and-labour-costs\/average-monthly-gross-wages-and-salaries<\/a><\/strong><\/li>\n<\/ul>\n<p>Example<\/p>\n<ul>\n<li>Start at 9, end at 16, hourly wage 11, days in a month 21.<\/li>\n<li>Results: Daily income 77, monthly income 1617.<\/li>\n<li>This is lower than the average gross income in Estonia!<\/li>\n<\/ul>\n<p>Some helpful materials: <a href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/resources\/introduction-to-algorithms-and-uml\/\">Introduction to algorithms and UML<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Due_week_3\"><\/span>Due week 3<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>Task: <\/strong>Continued development of the food scale program [W03-5]\n<p>Use your second week\u2019s second class assignment, in which you created the food scale application, as the base for this task.<\/p>\n<p>Add the following functionality to the application<\/p>\n<ul>\n<li>The allowed weighing range of the scale is 0 \u2013 50 kg<\/li>\n<li>The measurement uncertainty of the scale is \u00b110 grams plus 1% of the reading (mass)\n<ul>\n<li>For example, if the scale shows a mass of 2.00 kg, the actual mass may range from 1.97 to 2.03 kg<\/li>\n<\/ul>\n<\/li>\n<li>The menu must have two levels\n<ul>\n<li>From the first-level menu, the user selects a product category (e.g., fruits, vegetables). You must have at least 3 categories.<\/li>\n<li>From the second-level menu, the user selects a product within the chosen category. Each category must have at least 3 products.<\/li>\n<\/ul>\n<\/li>\n<li>The price offered to the user must take into account the entire measurement uncertainty in favor of the user \u2013 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.<\/li>\n<li>Error messages must be clear and correspond to the actual error that occurred. The application must be able to detect the following\n<ul>\n<li>No product on the scale (taking measurement uncertainty into account in both directions &#8211; e.g. if the scale weight is -5 grams or +2 grams, they both would mean no product on the scale)<\/li>\n<li>Faulty scale reading (e.g., weighing plate lifted)<\/li>\n<li>Overload (above the certified measuring range)<\/li>\n<li>Unknown product category<\/li>\n<li>Product missing from the selected category \/ unknown product<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>The solution will be defended in class. Make sure to have the source code ready to be presented.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Due_week_4\"><\/span>Due week 4<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>Homework:<\/strong> Model the algorithm of third week&#8217;s second lab task (cashier with input validation) as an activity diagram.<\/p>\n<p>The solution must be\u00a0 logically identical to your code.<\/p>\n<p>Some key aspects and hints<\/p>\n<ul>\n<li>To model loops, you must model all the elements of the loop\n<ul>\n<li>This includes the initial values, loop condition, loop body etc &#8211; depending on what the loop needs<\/li>\n<li>You must also pay attention to the differences of entry and exit control<\/li>\n<\/ul>\n<\/li>\n<li>If the loop also contained an <span class=\"lang:c highlight:0 decode:true crayon-inline \">if<\/span>\u00a0 statement, you need to model it as such &#8211; 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.<\/li>\n<li><span class=\"lang:c highlight:0 decode:true crayon-inline \">break<\/span>\u00a0 statements are not modeled as an action! Instead, break statements are just the change of the control flow &#8211; point it at where the program would continue execution.<br \/>\nThought process: nothing is being done when a <span class=\"lang:c highlight:0 decode:true crayon-inline \">break<\/span>\u00a0 occurs, instead the program proceeds to complete the next statement after the loop.<\/li>\n<li>Don&#8217;t forget the merge nodes. If you have two flows merging, you need a merge node.\n<ul>\n<li>If you only have one entering flow and one exiting flow, then a merge node is not usued.<\/li>\n<\/ul>\n<\/li>\n<li>Algorithms are programming language agnostic. You need to specify the sequence of actions, not 1:1 copy the statements from the program code\n<ul>\n<li>E.g. you shouldn&#8217;t used statements from the C language, such as printf, scanf. Also keywords like while, do .. while, for should be avoided.<\/li>\n<\/ul>\n<\/li>\n<li>When modelling conditional statements and mathematical operations, it can be helpful to both write the expression alongside the text. E.g.\n<ul>\n<li>Initializing the PIN attempt counter to 3, i.e. pinAttemptsLeft = 3<\/li>\n<li>Incrementing the PIN tries counter by 1, i.e. i++<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Some additional ideas can be found from a slightly more complex algorithm example: <a href=\"https:\/\/blue.pri.ee\/ttu\/resources\/introduction-to-algorithms-and-uml\/uml-example-filtering-positive-numbers-into-an-array\/\">UML example: filtering positive numbers into an array<\/a>.<\/p>\n<p>Solution is defended in the class. Make sure to have access to both the diagram as an exported image and the project file.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Due_week_5\"><\/span>Due week 5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>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.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Due_week_6\"><\/span>Due week 6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Write a program based on the task description: <strong><a href=\"https:\/\/blue.pri.ee\/ttu\/maaratlemata-en\/homework-age-grouping\/\">Age classifier<\/a><\/strong><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Due_week_7\"><\/span>Due week 7<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>Take the provided code here: <strong><a href=\"https:\/\/blue.pri.ee\/ttu\/files\/iax0583\/programmikood\/post.c\">post.c<\/a><\/strong><\/li>\n<li>The code is based on <strong><a href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/algorithm-tasks\/#Algorithm_5_Package_ratios\">Algorithm 5: package ratios<\/a><\/strong>.<\/li>\n<li>Translate the algorithm from the code to UML in its entirety.<\/li>\n<li>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 <span class=\"lang:default highlight:0 decode:true crayon-inline \">minInd = i<\/span>\u00a0 does not explain what is being done!)<\/li>\n<li>Details such as how many places after the comma to display or where to put a newline are not shown in the algorithm!<\/li>\n<\/ul>\n<hr \/>\n<p>No more home tasks past this point<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u00a0 week (i.e. homework for &hellip; <a href=\"https:\/\/blue.pri.ee\/ttu\/programming-i\/weekly-homework\/\" class=\"more-link\">Loe edasi <span class=\"screen-reader-text\">Weekly homework<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1425,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"page-templates\/code-width-wide.php","meta":{"footnotes":""},"class_list":["post-10290","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/pages\/10290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/comments?post=10290"}],"version-history":[{"count":15,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/pages\/10290\/revisions"}],"predecessor-version":[{"id":10916,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/pages\/10290\/revisions\/10916"}],"up":[{"embeddable":true,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/pages\/1425"}],"wp:attachment":[{"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/media?parent=10290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}