Professional Documents
Culture Documents
Programming For Engineers
Programming For Engineers
Programming For Engineers
1. Asks the user to choose one type of coffee out of three choices.
2. Tells the user what is the price of that coffee when its chosen and asks for amount of money
3. Tells the user that the money he or she entered is enough, more than enough and should get back some change less
than required and should give more
Write a MATLAB function that asks the user to enter series of 3 numbers and tells the user which numbers where
entered first and which number last and which number second.
myPalmReader
enter series of numbers in square brackets [ ] : [7 3 9]
you entered 7 first, 9 last and 3 second
Write a MATLAB function that takes numbers and sort them form bigger to smaller
Repeat the previous example by asking the user to enter the numbers, not making them arguments of the function
Write a MATLAB function that takes 2 numbers and gives back the first times the second if the first is smaller, and the
first divided by the second if the first is larger, and gives their addition if they are equal
Examples
myCrazyNumber(4,7)
your result is:
32 (this comes from 4*7 )
myCrazyNumber(4,2)
your result is:
2 (this comes from 4/2 )
myCrazyNumber(4,4)
your result is:
8 (this comes from 4+4 )
Loops
Write a MATLAB loop to list all numbers less than 1000 that can be divided by 4 without reminders.
Write a MATLAB loop to add all odd numbers between 10 and 1010
Write a MATLAB loop that asks the user to enter a number until he finds his lucky number
Example
Enter a number: 3
Not lucky, enter a number: 2
Not lucky, enter a number: 5
Not lucky, enter a number:6
Not lucky, enter a number: 4
Not lucky, enter a number: 7
Lucky YOU