CS155

CS155: Introduction to Unix                

Fall 2017                

HW 4                

CS155 HW4: Triangles!                

Nope, not those triangles. We’re talking about geometric triangles—three-sided polygons.                 

Summary                

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!

Testing                

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.                 

CommandOutput
./tsp 3 3 3equilateral
./tsp 3 4 5right
./tsp 5 4 3right
./tsp 4 3 5right
./tsp 6 7 8scalene
./tsp 102 100 102isosceles
./tsp 42 42 36isosceles
./tsp 1 2 9not 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

Requirements                

    #! /bin/bash

How to submit your homework:                

Follow the directions on the homework page.                 

How to receive fewer points:                

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.                 

How to receive negative points:                

Turn in someone else’s work.                 

Modified: 2017-08-26T16:35                 

User: Guest                 

Check: HTML CSS
Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building