CSCI 261 - Programming Concepts

Spring 2019 - A2 - Triangles

Quick Links: Canvas | Mines | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |

This assignment is due by Tuesday, January 29, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L2A, L2B, L2C, L2D, L2E .

· Instructions · Rubric · Submission ·

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 - Input Triangle Points


Write code to first read six real value measurements, i.e., your program should prompt the user to enter the six real values (which should be stored as six double variables). These six values correspond to the coordinates of the triangle vertices. The first two values make up the (X, Y) location of the first vertex, the next two values make up the (X, Y) location of the second vertex, and the last two values make up the (X, Y) location of the third vertex. A sample is below:

Enter the coordinates of the first vertex: 0 0
Enter the coordinates of the second vertex: 2.5 3
Enter the coordinates of the third vertex: 5 0


Instructions: Part II - Compute Side Lengths


Next, using these three points calculate the distance between each pair of points. These distances will correspond to the three legs of your triangle. Print this information to the user, displaying 3 decimal places at all times.

Enter the coordinates of the first vertex: 0 0
Enter the coordinates of the second vertex: 2.5 3
Enter the coordinates of the third vertex: 5 0

The side lengths are: 3.905 5.000 3.905


Instructions: Part III - Is It A Triangle?


Once done, write code to determine whether the three legs make a triangle (see hints below). If yes, your program should continue to Part IV below. If no, your program should politely terminate with an appropriate error message.

Enter the coordinates of the first vertex: 0 0
Enter the coordinates of the second vertex: 2.5 3
Enter the coordinates of the third vertex: 5 0

The side lengths are: 3.905 5.000 3.905
These sides do form a triangle.

Enter the coordinates of the first vertex: 0 0
Enter the coordinates of the second vertex: 1 1
Enter the coordinates of the third vertex: 2 2

The side lengths are: 1.414 2.828 1.414
These sides do not form a triangle. Have a nice day.


Hints


  • A triangle is possible IFF each side is smaller than the sum of the others.


Instructions: Part IV - Triangle Stats


If the result of Part III determines we do have a valid triangle, then we will continue to print out some stats about our triangle. We will print out both the perimeter and area of the triangle.

Enter the coordinates of the first vertex: 0 0
Enter the coordinates of the second vertex: 2.5 3
Enter the coordinates of the third vertex: 5 0

The side lengths are: 3.905 5.000 3.905
These sides do form a triangle.

The perimeter is: 12.810
The area is: 7.500


Hints




Grading Rubric


Your submission will be graded according to the following rubric.

PointsRequirement Description
2 All code submitted properly.
10 All labs completed and submitted
L2A, L2B, L2C, L2D, L2E
+2 Lab2E Extra Credit
2 In-class exercises completed.
2 Coordinates input correctly.
4 Triangle sides calculated and printed properly.
4 Correctly determined if sides make a triangle.
2 Triangle stats printed properly.
2 (1) Comments used
(2) Coding style followed
(3) Appropriate variable names, constants, and data types used
(4) Instructions followed
28 Total Points

This assignment is due by Tuesday, January 29, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L2A, L2B, L2C, L2D, L2E .


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. The following instructions are copied from How to Submit Homework.


It is critical that you follow these steps when submitting homework.

If you do not follow these instructions, your assignment will receive a major deduction. Why all the fuss? Because we have several hundred of these assignments to grade, and we use computer tools to automate as much of the process as possible. If you deviate from these instructions, our grading tools will not work. And that makes us very unhappy. And when we're unhappy, we give penalties. Thus, make us happy.


Submission Instructions



Here are step-by-step instructions for submitting your homework properly:
  1. File and folder names are extremely important in this process. Please double-check carefully, to ensure things are named correctly.
    1. The top-level folder of your project must be named Set2
    2. Inside Set2, create 6 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g. L2A, L2B, L2C, L2D, L2E, and A2).
    3. Copy your main.cpp into the subdirectories of Set2 (steps 1-2), zip this Set2 folder (steps 3-4), and then submit the zipped file (steps 5-11) to Canvas.
    4. For example, when you zip/submit Set2, there will be 6 sub-folders called L2A, L2B, L2C, L2D, L2E, and A2 inside the Set2 folder, and each of these sub-folders will have a file called main.cpp and nothing else.

  2. Using Windows Explorer (not to be confused with Internet Explorer), find the file named "main.cpp" located inside the folder for the particular lab or homework assignment you will submit.

    STOP: Are you really sure you are viewing the correct assignment's folder?

  3. Now, for A2, right click on the main.cpp to copy the file. Then, return to the Set2/A2 folder and right click to paste the file. In other words, put a copy of your homework's main.cpp source code into the Set2/A2 folder.

    Follow the same steps for L2A, to put a copy of your lab's main.cpp into the Set2/L2A folder. Repeat this process for Set2/L2B, Set2/L2C, Set2/L2D, Set2/L2E.

    STOP: Are you sure your Set2 folder now has all your code to submit?

  4. Now, right-click on the "Set2" folder.
    1. In the pop-up menu that opens, move the mouse "Send to..." and expand the sub-menu.
    2. In the sub-menu that opens, select "Compressed (zipped) folder".

    STOP: Are you really sure you are zipping a Set2 folder with sub-folders that each contain a main.cpp file in it?

  5. After the previous step, you should now see a "Set2.zip" file.

  6. Now visit the Canvas page for this course and click the "Assignments" button in the sidebar.

  7. Find Set2, click on it, find the "Submist Assignment" area, and then click the "Choose File" button.

  8. Find the "Set2.zip" file created earlier and click the "Open" button.

    STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?

  9. WAIT! There's one more super-important step. Click on the blue "Submit Assignment" button to submit your homework.

  10. No, really, make sure you click the "Submit Assignment" button to actually submit your homework. Clicking the "Choose File" button in the previous step kind of makes it feel like you're done, but you must click the Submit button as well! And you must allow the file time to upload before you turn off your computer!

  11. Canvas should say "Submitted!". Click "Submission Details" and you can download the zip file you just submitted. In other words, verify you submitted what you think you submitted!
In summary, you must zip the "Set2" folder and only the "Set2" folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this homework, and you must click the "Submit Assignment" button. Not doing these steps is like bringing your homework to class but forgetting to hand it in. No concessions will be made for incorrectly submitted work. If you incorrectly submit your homework, we will not be able to give you full credit. And that makes us unhappy.


This assignment is due by Tuesday, January 29, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L2A, L2B, L2C, L2D, L2E .

Last Updated: 01/22/19 23:06


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0