Professional Documents
Culture Documents
Computer Programming
Prof.: Amr El Mougy
TA: Rana Eisa
Quiz 2
November 27th, 2018
Name: ……………………………………………………………………………….
Max grade 15 15 15 30
Grade
1
ENGN 1310
Computer Programming
Prof.: Amr El Mougy
TA: Rana Eisa
For all questions in this quiz, you are required to write a working algorithm using Matlab.
You may use ANY command in Matlab that you like. Please note that syntax errors will
cost a lot of marks.
Question 1
Write an algorithm that can convert from mile to kilometer or from kilometer to mile, based on
input from the user.
The algorithm should first display a funky greeting message of your choice then ask the user
about the required type of conversion as well as the quantity to be converted. The output of the
algorithm is the converted quantity as well as its unit (mile or kilometer, depending on the
conversion type).
2
ENGN 1310
Computer Programming
Prof.: Amr El Mougy
TA: Rana Eisa
Question 2
The body mass index (BMI) is the ratio of the weight of a person (in kilograms) to the square of
the height (in meters). Write an algorithm that given the weight and height, computes the BMI,
and prints out the corresponding BMI category:
Starvation: less than 15
Anorexic: less than 17.5
Underweight: less than 18.5
Ideal: greater than or equal to 18.5 but less than 25
Overweight: greater than or equal to 25 but less than 30
Obese: greater than or equal to 30 but less than 40
3
ENGN 1310
Computer Programming
Prof.: Amr El Mougy
TA: Rana Eisa
Question 3 (bonus)
Chinese tradition assigns one of twelve zodiac signs to each year. After a twelve year circle, the
signs are repeated in the same order. The order is: Rat—Ox—Tiger—Rabbit—Dragon—
Snake—Horse—Sheep—Monkey—Rooster—Dog—Pig. Chinese New Year is usually in the
beginning of February, so a Chinese year can be approximately identified with a Western
calendar year. The last year of the Rat coincided with 2008.
Write a program that, given a year after 2013, gives the zodiac sign of the coinciding Chinese
year.