Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Write a program to read in three values which represent the lengths of the sides of a triangle.  Determine if the triangle is

Posted on 2010-08-31
5
Medium Priority
?
647 Views
Last Modified: 2012-05-10

1. An invalid triangle (the sum of any two sides is less than or equal to the third side)
2. Equilateral (all sides are equal)
3. Isosceles (any two sides are equal)
4. Right (The sum of the squares of the two legs is equal to the square of the hypotenuse.)
5. Regular (if none of the above apply).  If regular, also determine if the triangle is an
       A.   Acute triangle (the square of the longest side <= sum of the squares of the other
   two sides) OR
       B. Obtuse triangle (the square of the longest side exceeds the sum of the squares of
 the other two sides.)

The criteria listed above should be tested in the order given.  Treat the above criteria (1-5) as mutually exclusive so any particular case will satisfy only one criteria.

Process several cases of data with one run of your program and label all output appropriately.  

Input for each case: 3 integer values representing the lengths of the sides of a possible triangle
Output for each case: the 3 input values
           a message indicating the type of triangle OR an appropriate error message

Output to the screen.  Use the following data as sample inputs (input only the 3 integers):

Side 1            Side 2            Side 3

Case 1                  3            5            4
Case 2                  4            3            2
Case 3                  5            5            5
Case 4                  3            6            3
Case 5                  12            5            13
Case 6                  -7            -7            -7
Case 7                  7            5            5
Case 8                  0            5            0

Terminate processing only when all three input values are zero.  Print an appropriate error message if at least one side is equal to or less than zero but continue processing subsequent cases.
0
Comment
Question by:CS_Major2010
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 

Author Comment

by:CS_Major2010
ID: 33572119
im new to c++ if someone can help me to do this assignment  and help me write codes
0
 
LVL 32

Accepted Solution

by:
phoffric earned 2000 total points
ID: 33572710
Since a question is supposed to only ask one question at a time, and since a project usually has many question, it would be better to ask one question for this thread. I'll pick one question for you and give you a response.
====

How do you write code that can label the type of a triangle?

====
Your itemized list {invalid, Equilateral, Isosceles, ... } is a good candidate for an enumeration type. Here is an explanation of how to use this (has examples, too):
     http://www.cppreference.com/wiki/keywords/enum

From this link, you should be able write a few lines of code to create an object that has the labels for the type of a triangle. That would complete one step in your overall project.

====

Then you could ask another related question. For example:

I show below code for a function that accepts three sides of a triangle and is supposed to return the triangle type. But it does not compile. I get the following errors using the xyz compiler in the ABC operating system:
    - list the errors, including error codes

=====
Then after getting the errors fixed, you could ask another related question, for example:

I show below code for a function that accepts three sides of a triangle and is supposed to return the triangle type. But the program crashes (or maybe, the program returns the wrong answer).
0
 

Author Comment

by:CS_Major2010
ID: 33573567
thanks i wil try to do it the way u explained it and if i need help then i will ask for a solution
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question