Hey guys, I was wondering if you could help me out on an assignment I have to do for my introductory programming class.

Here is the link to the assignment:

http://www.cs.uwm.edu/classes/cs201/.../04/04/04.html

And here is my code so far:

Code:
```#include <iostream>
using namespace std;

int main ()
{

//Declare variables.
float A;
float B;
float C;

//Get lengths of triangle.
cout << "Please enter the triangle lengths:" << endl;
cout << "length 1: ";
cin >> A;
cout << "length 2: ";
cin >> B;
cout << "length 3: ";
cin >> C;

//Order the lengths.

if (A>B)
{
float temp;
temp = A;
A = B;
B = temp;
}

if (A>C)
{
float temp;
temp = A;
A = C;
C = temp;
}

if (B>C)
{
float temp;
temp = B;
B = C;
C = temp;
}

//Display order.

cout << "Lengths in nondecreasing order: "<< A << "," << B << ","
<< C <<endl;

return 0;

}```
Everything seems right so far...but I'm stuck as where to go from here. I have a lot of trouble with functions!

Any suggestions would be appreciated!

2. exactly what trouble are you having? no-one is going to do this assignment for you, but we're happy to help you along the way

to get you started on the functions. you need to declare them first
Code:
```#include <iostream>
using namespace std;

bool isTriangle(float x, float y, float z);
bool isIsoceles(float x, float y, float z);
bool isEquilateral(float x, float y, float z);
bool isScalene(float x, float y, float z);
bool isAcute(float x, float y, float z);
bool isRight(float x, float y, float z);
bool isObtuse(float x, float y, float z);

int main()
{
// code etc```
then define them after main
Code:
```} // end of main

bool isTriangle(float x, float y, float z)
{
// figure out if it's a triangle and
return true; // or false depending on answer
}```
you can then call isTriangle() in main()
Code:
```int main()
{
// snip
//Display order.

cout << "Lengths in nondecreasing order: "<< A << "," << B << ","
<< C <<endl;

if (isTriangle(A, B, C))
{
cout << "it's a triangle";
}
else
{
cout << "that's no triangle... ";
}
cout << endl;
return 0;

}```
that should get you started

3. Thank you for the quick reply...I'll take a look at this!

4. Okay, I got this far...but I'm not getting the same answers shown in the sample on the link.

Sorry if my code is long, I'm just a beginner!

Any suggestions?

Code:
```#include <iostream>
using namespace std;

//Function Prototypes.
bool isTriangle(float x, float y, float z);
bool isIsoceles(float x, float y, float z);
bool isEquilateral(float x, float y, float z);
bool isScalene(float x, float y, float z);
bool isAcute(float x, float y, float z);
bool isRight(float x, float y, float z);
bool isObtuse(float x, float y, float z);

//Main Function
int main ()
{

//Declare variables.
float A;
float B;
float C;

//Get lengths of triangle.
cout << "Please enter the triangle lengths:" << endl;
cout << "length 1: ";
cin >> A;
cout << "length 2: ";
cin >> B;
cout << "length 3: ";
cin >> C;

//Order the lengths.
if (A>B)
{
float temp;
temp = A;
A = B;
B = temp;
}

if (A>C)
{
float temp;
temp = A;
A = C;
C = temp;
}

if (B>C)
{
float temp;
temp = B;
B = C;
C = temp;
}

//Display order.
cout << "Lengths in nondecreasing order: "<< A << "," << B << ","
<< C <<endl;

//Function calls and final output.
cout<<"The triangle is: ";

if(isTriangle(A,B,C))
{
if(isIsoceles(A,B,C))
cout<<"Isoceles"<<endl;
}
else if(isEquilateral(A,B,C))
{
cout<<"Equilateral"<<endl;
}
else if(isScalene(A,B,C))
{
cout<<"Scalene"<<endl;
}
else if(isAcute(A,B,C))
{
cout<<"Acute"<<endl;
}
else if(isRight(A,B,C))
{
cout<<"Right"<<endl;
}
else if(isObtuse(A,B,C))
{
cout<<"Obtuse"<<endl;
}
else
{
cout<<"Illegal"<<endl;

return 0;
}}

//Function Definitions.
bool isTriangle(float x, float y, float z)
{
if (x>0 && (x + y >z))
{
return true;
}
else
{
return false;
}}

bool isIsoceles(float x, float y, float z)
{
if ((x=y) || (y=z))
{
return true;
}
else
{
return false;
}}

bool isEquilateral(float x, float y, float z)
{
if ((x=y) && (y=z))
{
return true;
}
else
{
return false;
}}

bool isScalene(float x, float y, float z)
{
if (x<y && (y<z))
{
return true;
}
else
{
return false;
}}

bool isObtuse(float x, float y, float z)
{
if (((x*x)+(y*y))<(z*z))
{
return true;
}
else
{
return false;
}}

bool isRight(float x, float y, float z)
{
if (((x*x)+(y*y))==(z*z))
{
return true;
}
else
{
return false;
}}

bool isAcute(float x, float y, float z)
{
if (((x*x)+(y*y))>(z*z))
{
return true;
}
else
{
return false;
}}```

5. Did you know that all Equilateral triangles are Isoceles triangles? So what are the outputs to the inputs of an Equilateral triangle when you say this?

Code:
```if(isIsoceles(A,B,C))
cout<<"Isoceles"<<endl;    // You had a } after this but no { before it
else if(isEquilateral(A,B,C))
{
cout<<"Equilateral"<<endl;
}```
By the way you had an extra } after this statement which is screwing with your output. You would see those things if you actually indented.

6. The format of your code is terrible. Everything should be indented properly, e.g.
Code:
```int num = 10;
if(num == 10)
{
cout<<num<<endl;
}
else
{
cout<<"no"<<endl;
}```
-----

Code:
```//Declare variables.
float A;
float B;
float C;```
Always initialize your variables. If you don't know what that means, look it up.
---

Code:
`nondecreasing order`
What the heck does "nondecreasing" mean? "Increasing"?

The basic strategy for writing a program is to write ONE function. Then, you test that function in main(). Once everything is working correctly, you move on and write another function. What you don't want to do is write 7 functions and then click on the compile button. So, start a new program and cut and paste your first function into your new program, and test it until it works. Continue on that way until you get all 7 functions to work.

7. you should also design your fuctions so that each function call is as complete as possible. In your case this means that in isIsoceles you should call isTriangle. This prevents error. we don't like error

8. Eh, I'm still clueless as to what to do....

7stud, sorry my code is sloppy, I'm using putty to write the code for my class and it doesn't automatically indent.

I think there is an issue with my "if" statements when calling the functions, because I keep getting an answer of "Equilateral" when the inputs I enter should come up with "Illegal".

Any suggestions?