I am trying to write a Java program using JCreator called Triangles that asks the user to enter three whole numbers representing the angles of a triangle. The purpose of the program is to determine, based on these numbers if the triangle is equalateral, isosceles or right angles.
If all angles are equal then I want to output the sentence using System.out.print, stating that this is an equalateral triangle. If only two angles are equal I want the sentence to state that this is an isosceles triangle. If any of the angles are 90o then I want to output a sentence stating that this is a right angled triangle.
So far I have:
String triangle(double angle1, double angle2, double angle3) {
if( (angle1 + angle2 + angle3) !=180)
return "Not a triangle";
else{
if(angle1 == angle2 || angle1 == angle3 || angle2 == angle3)
return "Isosceles";
if(angle1 == 90.0 || angle2 == 90.0 || angle3 == 90.0)
return "Right";
if(angle1 == angle2 && angle1 == angle3)
return "Equalateral";
}
}
2006-10-28
08:43:00
·
2 answers
·
asked by
Princess Peach
3
in
Computers & Internet
➔ Programming & Design