Sheet 3
Sheet 3
Write a MATLAB program which will ask the user for two numbers (you can use the
input function twice if you want). It should change the sign of the smaller of the two
numbers and then add them. The program should print a message informing the user of the
change in sign and also print out the final result.
2. Write a MATLAB program which asks the user to enter three numbers. The program
should figure out the median value and the average value and print these out. Do not use
the predefined MATLAB functions to compute the average and median values.
3. Write a MATLAB program which will ask the user for a number. If the number is equal
to two times a predefined number the program should print out a welcome message.
Otherwise it should print out a message saying you are not authorized.
4. Write a MATLAB program which will ask the user for their name. If the name matches a
list of three predefined names the program should print out a welcome message. Otherwise
it should print out a message saying you are not authorized.
5. Write a MATLAB program which will ask the user for a single Roman numeral (I, V, X,
L, C, D or M). The program should then print out its Standard English equivalent. Think how
you might extend this to get a Roman numeral to English numeral translator.
Roman numeral I V X L C D M
Standard English equivalent 1 5 10 50 100 500 1000
6. Write a MATLAB program which will ask the user for two numbers K and L. Using the
for loop find the sum of all numbers between K and L, that is
j
j k
8. The following sequence is called a Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 after
the first two elements each element of the sequence is the sum of the pervious two
elements . Write a MATLAB program which given the first two elements, will generate
and printout the next a elements of the Fibonacci sequence where a is a number supplied
by the user.
Good Luck
9. Write a MATLAB program which will prompt the user for a predetermined word if the
word is not correct it will ask again, and will keep asking until the user enters the correct
word. The program should print out the number of tries used to guess the word.
10. Write a MATLAB program which will ask the user to setup anew password. The
password should be at least six characters long. If the password entered by the user is less
than six characters long the program should issue a request to try again.
Good Luck