Calculating Triangle Area Using C++ Programming

Click For Summary

Discussion Overview

The discussion revolves around a programming project that requires calculating the area of a triangle using C++. Participants explore the implementation of Heron's formula, the triangle inequality, and the necessary programming constructs to handle user input and error checking.

Discussion Character

  • Homework-related
  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant suggests using Heron's formula to calculate the area of the triangle and checking the triangle inequality for validity.
  • Another participant expresses familiarity with the formula but not its name, indicating a need for clarification.
  • Several participants discuss the correct declaration of variables and the importance of using double for accuracy in calculations.
  • There is a correction regarding the implementation of Heron's formula, highlighting a mistake in the mathematical expression used.
  • Participants discuss the need to check if the sides form a valid triangle before computing the area, emphasizing the implications of negative values under the radical in the formula.
  • One participant proposes using if-else statements to handle the logic for computing the area or displaying an error message.
  • There are discussions about the placement of output statements based on the validity of the computed value r.
  • Participants express uncertainty about testing the program with negative values to trigger error handling.

Areas of Agreement / Disagreement

Participants generally agree on the use of Heron's formula and the necessity of checking the triangle inequality. However, there are ongoing discussions about specific implementations, variable declarations, and error handling, indicating that the discussion remains unresolved in some areas.

Contextual Notes

There are unresolved issues regarding the correct implementation of Heron's formula and the handling of user input, particularly in ensuring that the program correctly identifies when the sides do not form a valid triangle.

Who May Find This Useful

This discussion may be useful for students learning C++ programming, particularly those working on projects involving geometric calculations and error handling in user input.

  • #61
ineedhelpnow said:
he wants us to fulfill the second condition because he wants us to be able to code it properly. to have us use all the different types of commands and functions.

You are fulfilling the triangle inequality, with one statement, but you know your professor better than I do, so do what you think is best. :D
 

Similar threads

  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
Replies
1
Views
2K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
5
Views
3K
Replies
2
Views
3K
  • Sticky
  • · Replies 13 ·
Replies
13
Views
8K
  • · Replies 9 ·
Replies
9
Views
2K