Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
You are not logged in. Go to Login page. You need to login before you can view more content. (content omitted that requires login)
5. Triangle area
6. Requirements
Write a C program to do the following.
Input the unites of a triangle and the three points. Then print out the three points of the triangle, area of the triangle, and the direction of the three points.
If the requirements are unclear in any way, use any provided input and output to resolve the discrepancy.
Note: The formula used was missing a factor of 0.5 so this assignment actually calculated twice the area of the triangle. This is, the parallelogram made up of two such triangles.
7. Domain knowledge
Domain knowledge is the background knowledge that is useful in solving a problem, designing a solution, implementing the solution, etc. The following domain knowledge may be useful for this requirement.
Read each line of input using one scanf function, then echo that line of input using one printf statement. Otherwise, if there is an issue, you will not know at which line the issue happened.
When reading a string using scanf after some other input, the previous input needs to have a "\n" at the end of the string.
Do not use an absolute value function. Instead, is an if-then-else statement.
When converting the area to an absolute value, do not change the original area variable. Instead, create a new variable and set that value to the absolute value. The general rule is to, after setting a variable to an initial value, never overwrite the variable with a new value unless necessary. Instead, create a new variable and initialize that variable to the desired value.
Make all necessary assumptions. Make no unnecessary assumptions.
In addition to specific coding examples, you should be familiar with all concepts covered to this point in the course.
9. Diagnostic output
The program inputs an integer variable (without prompt) that determines whether diagnostic output is shown according to the following values.
If 0, no extra output is shown, just the final results (no condition necessary)
If 1, output from processing and the final result, are shown (condition "greater than zero").
If 2, all output, including prompts and echo, is shown (condition "greater than one").
10. Starter program
You are provided with the following starter program in file trianglearea.c.
Do not remove any comment that starts with three slashes.
Here is the C code.
You are to fill in the missing parts of the program according to the work requirements (see above).
In the comments at the top, you are to fill in the author (your name), help received (person and type of help), and pseudo-code parts which are not in the solution (usually provided, but you need to add them). Remove the parentheses too.
11. Possible solution
Begin solution
Here is a possible solution to the above problem. Note: Once a solution is provided, or the day before the next class, further submissions for this work receive no credit.
End solution
12. Examples of input and output
Here are some examples of input and output for the above program code.
Here is an example input from file input1.txt.
For the above example input, here is the expected output.
Here is an example input from file input2.txt.
For the above example input, here is the expected output.
Here is an example input from file input3.txt.
For the above example input, here is the expected output.
13. Pseudo-code
Pseudo-code is a "false" code. It is not really code, but a simplified English explanation that is somewhat similar to code. Pseudo-code is useful for understanding what a program does. For this work, the following can be used as the pseudo-code. Adjust if needed.
Note: Only some essential details are included. Some details, such as input, prompts, input echo, and obviously needed output are omitted.
The best way to copy-paste pseudo-code that includes indented code (e.g., with tabs) is as follows (in the code file) using a multi-line comment.
/*
(pasted pseudo-code here)
*/
14. Processing
It is best to separate input, processing and output into different parts of a program.
Since C has limited string handling capabilities (they can get complex), some processing involving string processing is moved to the output section of the code.
15. Scoring rubric
CS 101 - A5 : Asmt#5: Triangle area
Your grade: _ / 40
[LATE] Late or redo penalty: _ / -40
[SUBMIT] Not submitted properly: _ / -40
[RUN] Does not compile, run-time crash, etc.: _ / -40
[ETHICS] Ethical issues: _ / -40
[HEADER] Header comments not done as required: _ / -20
[STYLE] Inconsistant style or indentation: _ / -20
[CODE] Code guidelines ignored: _ / -40
[XCODE] Code used not yet covered: _ / -20
[REMOVED] Triple slash comments removed: _ / -20
[ADDED] Code added outside of marked areas: _ / -20
[OUTPUT] Functional requirements met: _ / 40
[CREDIT] Extra credit: _ / +8
Comments: