Need written in fortran 90 language, thanks! Question 4 4.1 Write a program to a
ID: 3587440 • Letter: N
Question
Need written in fortran 90 language, thanks!
Question 4 4.1 Write a program to accept three integer lengths and report back on whether these lengths could define an equilateral, isoceles or scalene triangle (3, 2 or 0 equal length sides), or whether they cannot form a triangle. Demonstrate that the program works by classifying the following: Sides of length 2 1 2 2 Hint: if three lengths form a triangle then 2 times the longest side must be less than the sum of all three sides. In Fortran 90 terms, the following must be true: 2 MAX (sidel,side2,side3)Explanation / Answer
program sum
REAL X,Y,Z
READ *,A
READ *,B
READ *,C
PRINT *,"SIDE 1 = ", A
PRINT *,"SIDE 2 = ", B
PRINT *,"SIDE 3 = ", C
if(2*MAX(A,B,C) < (A+B+C)) then
if(A==B .and. B==C) then
PRINT *,"EQUILATERAL TRIANGLE"
else
if(A==B .or. A==C .or. B==C)then
PRINT *,"ISOCELES TRIANGLE"
else
PRINT *,"SCALENE TRIANGLE"
endif
endif
else
PRINT *,"NOT A TRIANGLE"
endif
end program sum
/****************************************************
END OF PROGRAM
/****************************************************
SAMPLE INPUT 1:
6
6
6
SAMPLE OUTPUT 1:
SIDE 1 = 6.00000000
SIDE 2 = 6.00000000
SIDE 3 = 6.00000000
EQUILATERAL TRIANGLE
SAMPLE INPUT 2:
2
2
3
SAMPLE OUTPUT 2:
SIDE 1 = 2.00000000
SIDE 2 = 2.00000000
SIDE 3 = 3.00000000
ISOCELES TRIANGLE
SAMPLE INPUT 3:
6
7
8
SAMPLE OUTPUT 3:
SIDE 1 = 6.00000000
SIDE 2 = 7.00000000
SIDE 3 = 8.00000000
SCALENE TRIANGLE
SAMPLE INPUT 4:
1
1
0
SAMPLE OUTPUT 4:
SIDE 1 = 1.00000000
SIDE 2 = 1.00000000
SIDE 3 = 0.00000000E+00
NOT A TRIANGLE
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.