
CSC 145 Programming Assignment #1 - Is it a Triangle? What Kind?
Problem: Develop an Ada program to determine if three line segments form a triangle, and if
so, what kind (equilateral, isosceles, scalene) it is.
Data Structure: You will need to declare variables to hold the lengths of the line segments.
Process:
1. Get the three lengths, either from a data file or from the user.
2. Determine if they form a triangle.
3. If so, then determine what type of triangle is formed.
4. Display the three lengths.
5. Display the type of triangle or a message that they don’t form a triangle.
Questions to ponder:
1. Should the variables used for the line segment lengths be declared as INTEGER or FLOAT?
__________________ Why?______________________________________________________
______________________________________________________________________________
2. Does the logic of the program depend upon this decision?_____________________________
Why or why not?________________________________________________________________
3. If the three lengths are called A, B, and C, then the area of the triangle can be calculated by:
AREA =
S S A S B S C( )( )( )
, where S =
.
If you are also going to calculate the area, what type would you choose for the lengths and why?
______________________________________________________________________________
______________________________________________________________________________
Here are some sample data values to test your program:
3, 4, 5 4, 3, 5 5, 3, 4 5, 6, 12 6, 5, 11 10, 5, 6
4, 4, 4 4, 4, 2 4, 1, 2 4, 2, 4 2, 4, 4 1, 4, 2
Turn in a printed listing of your program and the output that it produces