next up previous
Next: About this document ...

ESC 251 HW 12 Due: Oct. 2

1)
(6 pts) Write a Fortran90 program 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

\begin{displaymath}A = \sqrt{s(s-a)(s-b)(s-c)}\end{displaymath}

where s is the semi-perimeter of the triangle

\begin{displaymath}s = \frac{a+b+c}{2}.\end{displaymath}

Test your program with the 3 sets of data: a = 4.1, b = 6.4, c = 10.1; a = 7.8, b = 12.0, c = 3.4 and a = 1.1, b = 2.2, c = 3.3. Extra credit (1 pts) if you can do this problem with only 1 IF statement with no compound testing.
2)
(5 pts) (Problem 3-9 in the book). 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 program 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

\begin{displaymath}\frac{\sin(\theta_1)}{\sin(\theta_2)} = \frac{n_2}{n_1}\end{displaymath}

where $\theta_1$ is the angle of incidence through a medium with a refractive index of n1 and $\theta_2$ is the angle of refraction through a medium with a refractive index of n2.



Write an F90 program that will ask the user to input values of $\theta_1$ (in degrees), n1 and n2 and computes the value of $\theta_2$ (provided the calculation is feasible). The value of $\theta_2$ 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)
$\theta_1 = 45^{\circ}, n_1 = 0.73, n_2 = 1.44$
b)
$\theta_1 = 45^{\circ}, n_1 = 0.58, n_2 = 0.13$




next up previous
Next: About this document ...
2017-09-29