CSC 145 Programming Assignment: Triangle Identification and Classification, Assignments of Computer Science

An ada programming assignment where the goal is to write a program that determines if three given line segments form a triangle and identifies the triangle type (equilateral, isosceles, or scalene). The document also includes questions to ponder regarding data types and calculations of the triangle area.

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-m09-1
koofers-user-m09-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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 =
( )A B C 2
.
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

Partial preview of the text

Download CSC 145 Programming Assignment: Triangle Identification and Classification and more Assignments Computer Science in PDF only on Docsity!

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:
  6. Should the variables used for the line segment lengths be declared as INTEGER or FLOAT? __________________ Why?______________________________________________________

  1. Does the logic of the program depend upon this decision?_____________________________ Why or why not?________________________________________________________________
  2. 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 = (^ A^ ^ B^ ^ C )^2. 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:

Turn in a printed listing of your program and the output that it produces