Nope, not those triangles. We’re talking about geometric triangles—three-sided polygons.                 
In this assignment, you will write a bash script called
tsp
which will classify a triangle. It will take, as command-line
arguments, the lengths of the three sides of a triangle, and classify
the triangle as exactly one of:
                
Right: | A 90° angle, per the Pythagorean Theorem: a²+b²=c². |
Equilateral: | All three sides are the same length. |
Isosceles: | Two sides, but not three, are the same length. |
Scalene: | No sides are the same length. |
Not a triangle: | For example, lengths of 1, 2, and 9. They just don’t fit together! |
Here are some of the ways that we will test your program. You can try your program with these arguments, and fix any problems you may have, or you can wait and let us find your problems. Your grade will reflect your choice.                 
Command | Output |
---|---|
./tsp 3 3 3 | equilateral |
./tsp 3 4 5 | right |
./tsp 5 4 3 | right |
./tsp 4 3 5 | right |
./tsp 6 7 8 | scalene |
./tsp 102 100 102 | isosceles |
./tsp 42 42 36 | isosceles |
./tsp 1 2 9 | not a triangle |
Here are some bad inputs, which must generate only an error message.                 
./tsp -3 12 99 |
./tsp 10 20 9-Jack-9 |
./tsp My Dog Kokopelli |
./tsp |
./tsp 42 |
./tsp 1 2 3 4 5 6 7 |
0 0 0
, it would be wrong for the
program to complain about the arguments not being ≥ 1, and then go on
to declare this an equilateral triangle.
Fish 0
, it doesn't matter which requirement you complain about.
Pick one, complain, and that should be all.
bash
script, and not use any other languages
such as perl or awk. You may use programs such as sed or grep.
#! /bin/bash
Follow the directions on the homework page.                 
Produce a poor error message. For example, “bad number” doesn’t tell me what argument it didn’t like, or what was so bad about it.                 
Turn in someone else’s work.                 
Modified: 2017-12-06T12:45                  User: Guest                  Check: HTML CSSEdit History Source |
Apply to CSU |
Contact CSU |
Disclaimer |
Equal Opportunity Colorado State University, Fort Collins, CO 80523 USA © 2015 Colorado State University |