I need help with my methods please?
import java.util.*;
public class Triangle3{
private static double b,h,side1,side2,side3,area;
public static void main(String[]args){
getSides();
getArea();
}
public static void getSides(){
Scanner in=new Scanner(System.in);
System.out.println("Enter a side of a triangle");
side1=in.nextDouble();
while(side1>0){
System.out.println("Enter another side");
side2=in.nextDouble();
System.out.println("Enter the last side");
side3=in.nextDouble();
if(side1==side2){
if(side3==side2)
System.out.println("Your triangle is an Equilateral Triangle");
}
if(side1!=side2){
if(side3==side2)
System.out.println("Your triangle is an Isoceles Triangle");
}
if(side1==side2){
if(side3!=side2)
System.out.println("Your triangle is an Isoceles Triangle");
}
if(side1!=side2){
if(side1==side3)
System.out.println("Your triangle is an Isoceles Triangle");
}
if(side1!=side2){
if(side2!=side3)
if(side3!=side1)
if(side2!=side1)
System.out.println("Your triangle is a Scalene Triangle");
}else{
System.out.println();
}
}
}
public static void getArea(){
side1=b;
side2=h;
area=0.5*(b * h);
System.out.println("The area of your triangle is " +area);
}
}
This program is suppose to find the area of a triangle after knowing what type of triangle and getting the sides. It looks bad because I'm only a beginner lol. Can I get some help as to why I can't get the second method to work?
Re: I need help with my methods please?
Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting.
Its hard to read your unformatted code.
Which method is the second one? Reading through your code makes it hard to count the methods. If you give the name of the method and what your specific problems with it that would help.