   Next: About this document ...

ESC 251 HW 11 Due: Sep. 28

Remember to indent the bodies of your IF-THEN statements.

1)
(2 pts) Enter the following commands into a script file and run it.
    a = 1.1;
b = 2.2;
c = 3.3;
if(c == a+b)
disp('c = a+b is true')
else
disp('c = a+b is false')
end

Does it give the correct output? What do you think is the reason for this behavior?
2)
(6 pts) Write a script that does the following:
a)
Asks the user to input three lengths a, b, and c
b)
Tests to determine if these lengths are capable of forming a triangle.
c)
If a triangle cannot be formed, an error message should be printed out. If (and only if) a triangle can be formed, your program should compute the area of the triangle using Heron's formula where s is the semi-perimeter of the triangle Test your program with the 2 sets of data: a = 4.1, b = 6.4, c = 10.1; a = 7.8, b = 12.0, c = 3.4.
3)
(5 pts) The income tax in Australia is computed according to the following table:
 Taxble Income Tax Owed $0 -$6,000 $0$6,001 - $20,000$0.17 for each $1 over$6,000 $20,001 -$50,000 $2,380 plus$0.30 for each $1 over$20,000 $50,001 -$60,000 $11,380 plus$0.42 for each $1 over$50,000 over $60,000$15,580 plus $0.47 for each$1 over $60,000 In addition, a 1.5% tax is charged on all income regardless of the taxable amount. Write a script that will compute the income tax owed given the amount of taxable income. Test your program for income amounts of$5,015, $14,678,$55,784 and \$75,000.

3)
(6 pts) When a light ray pssses from one medium to another, the light ray gets bent. Snell's Law of Refraction is the relationship that determines how much a light ray will bend. It states where is the angle of incidence through a medium with a refractive index of n1 and is the angle of refraction through a medium with a refractive index of n2.

Write a script that will ask the user to input values of (in degrees), n1 and n2 and computes the value of (provided the calculation is feasible). The value of should be printed out in degrees. In the event that the calculation is not feasible, an error message should be printed out.

Test your program using the 2 cases

a) b)    Next: About this document ...
2018-09-26