CSCI 261 - Programming Concepts (C++)Spring 2018 - Assignment 2 - Random TrianglesQuick Links: Canvas | CS @ Mines | Cloud9 | Piazza | zyBooks |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This assignment is due
by Tuesday, January 30, 2017 11:59 PM.
As you will learn, we LOVE triangles in this class. (And I particularly love
them in the computer graphics
class). Get ready to learn more than you'll ever want to about geometry and triangles.
Instructions: Part I - Classify Their Triangle
Write code to first read three real value measurements, i.e., your
program should prompt the user to enter the three real values (which
should be stored as three double variables). Once done, write code to
determine whether the three real value measurements make a triangle. If
yes, your program should tell the user whether the triangle is a right,
acute, or obtuse triangle (see hints below). If
no, your program should politely terminate with an appropriate error
message.
The user should be allowed to enter
the three real values in any order; in other words, your program should
not assume any particular input order such as ascending or descending.
Hints
// The fabs function (defined in cmath) returns the absolute value of
a given floating point number.
// Thus, if the following equation is true, then we assume a2 + b2 == c2. fabs(a2 + b2 - c2) <= TOLERANCE Test Values
Here are some known input/output values that you can test against. Be sure to try your own to verify
the code works!
Instructions: Part II - Triangle StatsIf the result of Part I determines we do have
a valid triangle, then we will continue to print out some stats about our triangle. We first
will want to print out the three sides in increasing order. Then, we will print out both the
perimeter and area of the triangle.
Hints
Test Values
Here are some known input/output values that you can test against. Be sure to try your own to verify
the code works!
Instructions: Part III - Randomize The TriangleNow for the tricky part. We are going to go back and edit what we did at the very beginning.
Initially, the user was entering the length of the three sides. Instead, we want to ask the user to enter the first two sides of a triangle.
We then need our
program to generate a third random real side length that results in a valid triangle. Given the hints
above, what can the minimum and maximum possible values be? The rest of the program will then proceed as before using
the randomly generated value.
Grading Rubric
Your submission will be graded according to the following rubric.
Submission
Always, always, ALWAYS update the
header comments at the top of your main.cpp file. And if you ever get
stuck, remember that there is LOTS of help
available.
From your Cloud9 workspace, right
click on the Set2 folder in your workspace tree. Select "Download"
from the pop-up menu. This will download a file called Set2.zip to your computer. It
contains all the files of your Set2 folder (therefore L2A,
L2B, L2C, L2D, L2E, A2).
Now in Canvas, go to Assignments > Set2. Upload your
Set2.zip file you just downloaded. And voila! Easy
peasy.
In summary, follow these specific steps:
This assignment is due
by Tuesday, January 30, 2017 11:59 PM.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Last Updated: 01/08/18 15:57
|