You are on page 1of 2

BENHA UNIVERSITY Faculty of engineering

Computer
Programming
Mechanical engineering department 3rd year (Power)

Assignment (3)
Unless instructed otherwise, draw a flowchart for every problem that calls for a
Matlab program to be written. Also use remark liberally % to explain some tasks in
the program.
1. A student took four tests. His marks were 100, 86, 71, and 92. Write a
computer program to calculate his average score.
2. Write a Matlab program to calculate the average of a given list of N
numbers by using (FOR loop)
3. Calculate the graduation grade (Excellent when score  85, very good
75, good  65, pass  50, and fail <50) of a student. Let the student
name and average score of the subjects is the input, and the output is
the student name and the grade.
4. A customer put in an order for four books which retail at 519.5 LE and
carry a 25% discount, three CDs at 39.8 LE with 15% discount, and one
CD player for 139.95 LE on which there is no discount. In addition, there
is a 2.0% discount allowed on the total order for prompt payment. Write a
program to compute the amount of the order.
5. Draw a flow chart and write a Matlab program and to compute the roots
of quadratic equation. Write a script which will ask for the coefficients of
the quadratic equation and display the resulting roots with some sort of
comment. Where, the roots can be calculated by the following relation;
−𝐵 ± √𝐵 2 − 4𝐴𝐶
𝑠1,2 =
2𝐴
Solve the following equations and get the output of the Matlab answer in
your answer sheet, s2+5 s+6, 3s2+9 s+4, and 2s2+8 s+8
Dr. Mohamed Saber Sokar 1/2
6. A man is paid 10 LE the first day on the job, 20 LE the second day, 40
LE the third day, and so on, doubling each day on the job for 30 days.
Write a Matlab program to calculate his wages/salary on the 30th day and
his total for the 30 days.
7. Write a Matlab program to print the integers from 1 to 25 paired with their
reciprocals.
8. Write a program to print all of the prime positive integers less than 100.
9. Calculate the geometric average of a list of n numbers, use the following
formula G = n x1 x2 x3 ... xn

Find the compound interest on $1000 at 5% compounded quarterly for


10 years. Print the amount after each year with the year number. Select
the suitable formula to write a M-script to get the answer
Hint: Annually A = P × (1 + r) = (annual compounding)
Quarterly A = P (1 + r/4)4 = (quarterly compounding)
Monthly A = P (1 + r/12)12 = (monthly compounding)
Where p is the Principal (initial amount of investment), r is annual rate of
interest, A total amount of accumulated after n years

Dr. Mohamed Saber Sokar 2/2

You might also like