Assignment – Trimester 2, 2020
Computing and Programming
Date: Friday Week 8, 21st August 2019, 23:59
Coordinator Name: Dr. Seyedali Mirjalili
Read these instructions
Attached is your assignment. There are four questions and you must answer all of them. Your answers must include a written document that briefly, but concisely explains how your programs works.
Put all your ‘m’ files in a zip file which named your_student_id .zip eg: ALFRD1304.ZIP
Your zip file must be emailed to me at ( firstname.lastname@example.org ) before the due date.
As part of the marking of the assignment, students should be prepared to verbally explain how sections of the code function.
Any plagiarism identified in assignments will be considered academic misconduct and academic penalties will apply. A definition of plagiarism from the Griffith Institute for Higher Education, Good Practice Guide is attached.
Plagiarism can take any of the five following forms:
Verbatim copying Copying word for word without any acknowledgement of the source
Incorrect/inadequate acknowledgement: Verbatim material incorrectly noted as having been paraphrased, or material that has been paraphrased and has not been acknowledged adequately.
Collusion: Copying material from another’s assignment with his/her knowledge.
Ghost writing: Submitting an assignment as your own when it has been written by a third party.
Purloining or appropriation: Copying material from another’s assignment without his/her knowledge.
1. Guessing game in Matlab (5 marks) Difficulty
? When the program starts, a random whole number, n, is selected where: n = 1 and n = 200
? The user enters a guess and the program displays
? “higher” if the guess is less n
? “lower” if the guess is greater than n
? “correct” if the guess is equal to n
? The game continues until the user enters a correct guess and then the program quits
? When the program quits, the total number of guesses is displayed as the score
2. Rolling Dice Simulator in C (6 marks) Difficulty:
• As the title suggests, this question involves writing a program that simulates rolling dice. When the program runs, it will randomly choose a number between 1 and 6. (Or whatever other integer you prefer — the number of sides on the die is up to you.)
• The program will print what that number is.
• It should then ask you if you’d like to roll again.
• For this question, you will need to set the min and max number that your dice can produce. For the average die, that means a minimum of 1 and a maximum of 6.
3. Number Sorter in Matlab (6 marks) Difficulty:
? Must be a console program
? Reads integers from standard input (i.e from the user via the keyboard) until a number less than or equal to zero is input. This indicates the end of input.
? Once end of input is detected, the program sorts all of the numbers in ascending order and displays them ? You can choose any sort algorithms. For instance:
? choose a random input, n, not yet sorted in the list of input values
? go through the list of input values and place all values less than n to the left of n and all other values to the right of n
? Once this is done then n is sorted, so go back and repeat the first step
? Once all values n are sorted the entire list is sorted
? You are not allowed the built-in function sort in Matlab to solve this problem.
4. Hangman game in Matlab (8 marks) Difficulty: 4
? Must be a console program
? Characters are in mixed case (upper and lower case, where A Z a z) but they should be treated similarly when the user make guesses
? Randomly select a word from a list of words, have the user guess characters in the word.
? For each character they guess that is not in the word, have it draw another part of a man hanging in a noose. If the picture is completed before they guess all the characters, they lose.
? You can use the following statements to illustrate the hang man:
disp(' _________ ');
disp('| | '); disp('| 0 '); disp('| /| '); disp('| / '); disp('| '); disp('| '); Documentation:
• For each question, you need to thoroughly explain your code.
• A minimum of 200 words should be written for each question
• You need to explain how and why you have designed your program that way.
• Particularly, justify and elaborate the use of structured statements in you code including loops and selections.
General Requirements – Coding conventions/practices
Marks are awarded for good coding conventions/practices such as:
• Consistent use of spaces or tabs for indentation. We recommend 4 spaces for every level of indentation. Be careful to not mix tabs and spaces. Each “block” of code should be indented one level.
• Keeping line lengths of code to a reasonable maximum such that they fit in the default terminal screen width (80 characters wide).
• Complete author identification on all files.
• Appropriate variable names.
Marks will be deducted for the following:
• Compile errors and warnings.
• Fatal run-time errors such as infinite loops, etc.
• Missing files (affected components get zero marks).
• Files incorrectly named
• Not identifying yourself in all files submitted
• Programs with compile errors that cannot be easily corrected by the marker will result in a maximum possible score of 30% of the total available marks for the assignment.