
Programming Aerospace Engineering, 2020-21
1
Lab 6 (Arrays - II)
Exercise 1. Vending machine
Write a program to manage a vending machine. The program should prompt the user for the price of the
product to be bought, the money provided, and compute the corresponding change. The program should
display how many coins of each type should be returned. The types of coins to be considered are 1, 2, 5, 10, 20
and 50 cents, and 1 and 2 Euros. Assume there are enough coins of all types to give change.
Tips: Do the math in cents!
Exercise 2. Vending machine with limited change
Modify the previous exercise so that the change is computed assuming that there is only a limited number of
coins of each type available. The amount of coins available can be either entered by the user, random or
defined directly in your code (the last option will speed up your testing of the program)
For example, this initialization can be used to set the number of coins of each type available to 2
nCoinsAvailable = [1 0 5 1 0 0 0 100];
Exercise 3. Zebra mussel
In recent years, the zebra mussel is colonizing the Ebro River threatening the local species. To study the process
of colonization, 50 control points have been established. The number of mussels found at each point every
month is recorded.
The objective of this exercise is to develop a program to study the number of mussels found at each of the 50
control points during a maximum of 24 months. The program will display the number of mussels found at each
point and the control point where the maximum number of mussels were found.
Write a MatLab program that:
1. Asks the user to input the number of mussels found at each control point for each month. Each control
point will be identified by a number (1, ... 50). The user must provide this information for at least one
month and a maximum of 24. After reading the information for a month, the program must ask the user
whether he/she wants to continue providing data for one more month or not.
2. Displays the total amount of mussels found at each control point along the study. The program must
print the number of each control point ( 1, 2, ..) followed by the total sum of mussels found at that
point.
3. Displays the total amount of mussels for the control point where the most mussels have been found
(total amount=sum of all months). You must also print the number of that control point.
4. Print in how many months any mussels were found at each control point. That is to say, for each control
point, compute in how many months the number of mussels found is different to 0.
5. Display the total number of specimens found in the study