0% found this document useful (0 votes)
4 views2 pages

Sheet 3

The document outlines ten MATLAB programming tasks that involve user input and various programming constructs. Tasks include changing the sign of numbers, calculating median and average without predefined functions, validating user input against predefined criteria, converting Roman numerals to English equivalents, summing numbers in a range using loops, generating Fibonacci sequences, and managing password setup with length validation. Each task emphasizes the use of conditional statements and loops to achieve the desired functionality.

Uploaded by

gamalmoh143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Sheet 3

The document outlines ten MATLAB programming tasks that involve user input and various programming constructs. Tasks include changing the sign of numbers, calculating median and average without predefined functions, validating user input against predefined criteria, converting Roman numerals to English equivalents, summing numbers in a range using loops, generating Fibonacci sequences, and managing password setup with length validation. Each task emphasizes the use of conditional statements and loops to achieve the desired functionality.

Uploaded by

gamalmoh143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

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.

Solve by using if-statement and repeat it by switch-case.

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.

Solve by using if-statement and repeat it by switch-case.

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

Solve by using if-statement and repeat it by switch-case.

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

7. Repeat the pervious program using the while loop.

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

You might also like