CSCI 261 - Programming Concepts (C++)Spring 2017 - Assignment 02 - Hello TriangleQuick Links: Blackboard | Canvas | CS @ Mines | Cloud9 | Piazza | zyBooks |
|||||||||||||||
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |||||||||||||||
This assignment is due
by January 24, 2017 11:59PM.
We Love Triangles
You'll soon start to figure out how much we love triangles (they have
some wonderful properties). To get started, create an empty project
called
A02
and copy the code below for your
main.cpp
.
/* CSCI 261 A02: Triangles * Author: XXXX (_INSERT_YOUR_NAME_HERE_) * * Add more complete description here... */ #include <iostream> // For cin, cout, etc. using namespace std; // For standard namespace int main() { // PART I: INSERT YOUR CODE BELOW HERE // PART I INSERT YOUR CODE ABOVE HERE // PART II: INSERT YOUR CODE BELOW HERE // PART II INSERT YOUR CODE ABOVE HERE // PART III INSERT YOUR CODE BELOW HERE // PART III INSERT YOUR CODE ABOVE HERE return 0; // signals the operating system that our program ended OK. }
There are three short programming assignments with this homework
assignment. You should put your solutions to all three of these short
assignments in one
main()
. Please use comments above to see where code from each assignment
begins/ends. Before moving on to the three parts, take time to update
the header comments at the top of your
main.cpp
file. Also, make sure everything runs fine before moving on to the next
step.
Instructions - PART I: Generate PointsUsing a random number generator, first
generate an (X, Y) location to represent one vertex of our triangle.
Use two integer variables to store this (X, Y) location and generate
random values in the range [-10, 10] for each value. Display this
starting point to the user.
Then ask the user to enter two more
(X, Y) values to represent the remaining two vertices of our triangle.
It is possible the user could enter any real value for these values, so
choose the appropriate data type.
Instructions - PART II: Calculate Some Triangle PropertiesNow that we have three vertices
representing a triangle, let's computer some useful properties of a
triangle:
Instructions - PART III: Print Those PropertiesExcellent. Now let's print these
numbers to the user. It's possible some of our calculations could be
fractional in nature, so we will display two decimal places to the user
at all times. To make our side lengths easy to read, we'll also need the decimal places aligned for quick comparison.
The first point is: 10 -5
Enter coordinates for the second point: 2.5 3 Enter coordinates for the third point: 5 0 Sides of the triangle are: 3.91 5.00 3.91 Perimeter of the triangle is 12.81 Area of the triangle is 7.50
Requirements: you need to use the
cmath
library and I/O manipulators in your solution to this assignment.
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.
For homework due on Tuesday, January
24 follow these specific steps:
This assignment is due
by January 24, 2017 11:59PM.
| |||||||||||||||
Last Updated: 01/01/70 00:00
|