For homework 2, you need to create a software solution to solve a problem given to you in your variant, based on the requirements. The solution must be properly documented.
The focus of this homework is creating, using and documenting user-defined functions. There is an additional focus on analysis of possible problematic user inputs, and if possible, handling of those erroneous inputs. This again, needs to be documented.
For testing, you are expected to use stream redirection.
NB! The video is to explain the concept of HW2. The captured page of the task may not be the most recent version of the requirements! Make sure that all the requirements are fulfilled based on the current version of this page!
Documentation template
Use the same templates as you used with Homework 1 (https://blue.pri.ee/ttu/programming-i/homework-i/) and adjust it to fit the requirements of this homework.
Documentation
- Title page
- Declaration of originality
- List of abbreviations and terms (can be omitted if not present)
- Table of contents
- List of figures and tables (can be omitted if not present)
- Task description
- Description of the solution (2 – 4 A4 pages).
Description must be well structured. Use tables, lists, figures, subheadings etc. It should not be a wall of text!- What is the purpose of Your program? What does it do?
- Explain the program’s input (where does the input come from, in which format must it be in, in which order are inputs expected and if there are any limitations to input values).
- Program flow (in which order are things done, be brief and generic)
- Special situation analysis and handling
- Analyze various situations (inputs) that can cause errors or issues with your program
- Give a solution for each of the issues (if possible). Explain why you chose each of the solutions (e.g. you can compare it with an alternative).
- NB! You should also list issues that you are unable to solve with your current knowledge (or experience), but you are aware of. You are also welcome to propose an idea how to go about solving it.
- Summary
- Write a few sentences about your approach to the task and progression during it.
- Write a few sentences about the task itself and the complexity of it.
- If possible, give an estimate on the workload.
- Additional comments, emotions, thoughts
- References (can be omitted if not present)
- Everything that wasn’t covered within the subject and that you didn’t create on your own.
- This includes help from a friend or a colleague: https://libraryguides.vu.edu.au/ieeereferencing/personalcommunication
- If you used AI tools (i.e. ChatGPT), they must also be referenced
- All references must be precise. References such as stackoverflow.com or google.com are meaningless. It must be directly to the page where you got the information from.
- Appendix: Screen capture(s) of the working program
- You must show your program running through stream redirection.
- Screen captures should illustrate various situations that you program can handle, as well as the normal behavior.
- Screenshots can be added as an appendix or embedded within the write up of the solution – in this case you can extend the length by 1 page.
Requirements for input
The program you create can be used in two different ways
- Through stream redirection. This will affect the requirements for the order of inputs that your program must accept. More information about this under “input file structure”.
- Executing the program normally, waiting for prompts and writing inputs on the keyboard. This requires the input prompts for the user to be clear, as well as provide feedback for faulty inputs.
Your program must work with up to 15 inputs. This means that for 1-dimension arrays, you may have 15 values and for 2-dimensional arrays you may have 15 x 15 values.
You are provided with 2 text files with your task variant, that contain sample inputs. Your program must read the inputs in the same order as given in those files. Those files will also be your first test files.
Part of your task will be to analyze and solve various situations that your program may come across. E.g. what happens if you are expecting a positive integer, but the user decides to give you a negative one? Or instead of multiple values to analyze, the user only gives you 1. For those situations, you should also create additional input files for testing.
We will however not be testing your program in situations where the inputs are given out of order or in a different data type. E.g. if you are expecting an integer, you will be getting an integer (we will not write a string).
Input file structure
The first number in the input file will always describe the amount of inputs following it. If it’s a matrix, two numbers will precede the data.
E.g. an input file for finding the average grade: 9 1 0 4 5 5 3 5 4 2
The first number 9 indicates how many grades will follow, after which there will be 9 grades.
Requirements for the standards and environment
The program must be written in the C programming language. You are permitted to use the C90 and C99 standards. Upon an agreement, you can also use newer standards such as C11 and C17.
Program can only use standard libraries. Upon an agreement, you can ask to also use POSIX C and GNU C libraries.
The program must compile and work in Linux, however it is preferred to have a program that is not operating system dependent. Your program will be compiled and tested in a Linux environment, equivalent to the one in the lab computers (e.g. OpenSUSE SLED-15 SP5 or Ubuntu Linux 22.04, using GCC-11 compiler).
Program requirements
- Code must adhere to the practices taught in the class so far.
- Your program must read the input from stdin standard stream. We will test your program by both running it with stream redirection and running it normally, typing the inputs on the keyboard.
- Must not contain any unused components – e.g. libraries, variables, .. that are not used.
- At minimum, the functions specified in the task variant are implemented. You may need more than that though.
- If there is repetitive code, you must create a function and solve the repetitions using function parameters.
- Data must be passed to the functions using parameters only and received from those functions using return values. Global variables are not allowed.
- Function prototypes are before the main() function, function body is written after the main() function
- All of the coding style requirements are met, including
- All functions are commented using the standard function commenting style (description, parameters, return value).
- Names of the functions, variables and preprocessor macros are self-explanatory and formatted correctly.
- Your code file has a comment in the heading of it stating what the program does, who the author is etc.
Extra task for bonus points
It’s possible to receive up to 2 bonus points for the task.
To get the bonus points, the following requirements must be met in addition to completing all the basic requirements. It’s also possible to get points for partially solving the extra task requirements, as long as they are correctly documented.
Additional requirements:
- The application must support the following command line arguments
- -i=file_name and --input=file_name – Program reads the input from the given file and prints the results immediately.
- -p=interactive and --prompt=interactive – Program reads input from stdin standard stream. The program must clearly express what it requires from the user and print error messages as they happen. This is the default option.
- -p=disabled and --prompt=disabled – Program reads input from stdin standard stream. The program must not present the user with any prompts for input. Only the results are displayed.
- --help – Prints a guide how to use the program using the classical help page structure and style (Some examples: grep --help and man grep )
- The program must not break down if the user enters a string instead of an integer.
- Program reads input from stdin standard stream.
- You must add a level 1 heading to the documentation called “Extra task”.
- Describe the added features
- Describe how you approached adding and checking the command line arguments
- Describe how you decided what was important to be displayed on the help age
- Explain your approach to input validation so that the program wouldn’t break on invalid input.
Deadlines, points and bonuses
A complete homework must be submitted no later than 15.12.2024 23:59:59 (local time)
Every week passed the deadline removes 1p from the maximum possible score. The late cost is capped at 5p, meaning if you submit 7 weeks late, you can still get up to 10p.
If we have questions about the submitted homework or are not sure about the original author of this work, we will grade this with 0p. In this case, the work must be defended.
If it becomes necessary, we will enforce the rules and guidelines of [Procedure for processing a student’s violation of academic practices and contemptible behavior in the School of Information Technologies]
We will only accept Your homework until the lockdown date (check introduction slides). Past that, submitting your homework will not be possible.
Submitting Your work
You need to submit the documentation in Adobe PDF format, all the necessary code files to compile your program and a zip archive with the test inputs, which should include additional inputs created by you.
Naming schema: HW2_<studentcode>_<firstname>_<lastname>
Example:
HW2_123456MVEB_Heli_Kopter_code.c
HW2_123456MVEB_Heli_Kopter_report.pdf
HW2_123456MVEB_Heli_Kopter_inputs.zip
Submitting is done using Moodle:
https://moodle.taltech.ee/course/view.php?id=31001
Result and feedback
After your work has been checked and graded, you will see the result and feedback on Moodle (visible from your gradebook only!). If everything was well done, feedback may be absent.
Fixing your homework
You are allowed to fix and improve your homework score until the date of homework lockdown. All fixed submissions are subject to defense.
To fix your homework, first go through your feedback. Then contact your teacher and agree upon the process of how this homework can be fixed.
NB! If fixing the homework changes more than half of the original homework, it is considered as submitting a completely new homework, from which minus points can be deducted from depending on the time of submission.
NB! This is only a partial solution displaying some parts of the testing, code style and creating a title page. We expect a full report as described in the requirements.