Assignment – Semester 1, 2017
1004ENG
Introduction to Computing and Programming with MATLAB
Date: Friday Week 11, 19th May 2016
Weighting: 20.00%
Marks: 20
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 .zip
.
1. Guessing game (4 marks: 2 for code 2 for document) Difficulty: 1
Requirements:
● When the program starts, a random whole number, n, is selected where: n>= 1 and n <= 100
● 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. Screen saver-bouncing name (4 marks: 2 for code 2 for document) Difficulty: 2
Requirements:
● Must be a graphics program
● When the program starts, the program needs to read a name from the user
● You program should then display the name on the screen in a random location
● The name continues to move along a random path until it hits the edge of the window
● The name bounces off the window and the process is repeated indefinitely
● You can get extra marks if multiple names bounces and for any visual/audio effects
3. Password Checker (6 marks: 3 for code 3 for document) Difficulty: 3
Requirements:
These days, many systems require users to have passwords that meet certain criteria to make them harder to compromise. At Griffith College, your password must be of a certain minimum length (8 characters) and contain upper and lower case letters and at least 1 number.
For this problem, you need to write a function to verify the integrity of a password. The function should have the following formal definition.
function [ output ] = isValidPassword ( password )
Implement the above method to verify that a provided password meets the following criteria:
• Password must be at least 8 characters long
• Password must contain at least 1 number, 1 lowercase letter and 1 uppercase letter
• Password must contain at least 1 non alpha-numeric character from the below list: o ! @ # $ % ^ & * ( ) [ ] \ | ? /
• Password should NOT contain any character that is not a letter or a number or on the above list.
When you finish the method, write a scrip file and test the function with several examples. You may use a while loop to get the user to type a password and check it as well.
4. Polygon Drawer (6 marks: 3 for code 3 for document) Difficulty: 4
Requirements:
● Must use plots
● The program reads the position of mouse every time the user clicks on the plot and draws a line from the previous and current position of the mouse (assuming that the first line is drawn from 0,0 to the position of the mouse in first click.
● The program displays a corresponding polygon in a window
● There program must allow the user to draw lines until he clicks somewhere close to the origin (0±0.1, 0±0.1)
● After clicking near the origin, your program should calculate the perimeter of the polygon and display it either in the figure or command window.
Tips:
● You can easily get the position of mouse using [X,Y]=ginput(1); where 1 is the number of points that you would like to read from the mouse at once
Example:
Documentation:
For each question, you need to write a section as follows:
Q1:
Section 1:
• User manual
• Overall structure and operation of your program
• Incomplete submission only: how far have you completed? What was the main challenge?
Section 2:
Flow chart and pseudo code
Section 3:
How? Why?
You need to explain how and why you have designed your program that way. Particularly, explain why you have used if-elseif-else and not if-else, why while loop, why for loop , etc
Example:
• We had to use a while loop because we don’t know …
Q2:
Section 1:
• User manual
• Overall structure and operation of your program
• Incomplete submission only: how far have you completed. What was the main challenge?
Section 2:
Flow chart and pseudo code
Section 3:
How? Why?
You need to explain how and why you have designed your program that way. Particularly, explain why you have used if-elseif-else and not if-else, why while loop, why for loop , etc
Q3:
Section 1:
• User manual
• Overall structure and operation of your program
• Incomplete submission only: how far have you completed? What were the main challenges?
Section 2:
Pseudo codes only
Section 3:
How? Why?
You need to explain how and why you have designed your program that way. Particularly, explain why you have used if-elseif-else and not if-else, while definite loop, why for loop , etc
Q4:
Section 1:
• User manual
• Overall structure and operation of your program
• Incomplete submission only: how far have you completed? What were the main challenges?
Section 2:
Pseudo codes only
Section 3:
How? Why?
You need to explain how and why you have designed your program that way. Particularly, explain why you have used if-elseif-else and not if-else, while definite loop, why for loop , etc
Good luck!