三角形问题:
import java.util.Scanner;
public class sanjiaoxing
{
public static void main(String[] args)
{
System.out.print("Enter 3 integers which are sides of a triangle:\n");
Scanner input=new Scanner(System.in);
double a=input.nextDouble();
double b=input.nextDouble();
double c=input.nextDouble();
System.out.println("side a is:"+a+" side b is:"+b+" side c is:"+c);
boolean istriangle=true;
if((a+b)<=c || (a+c)<=b || (c+b)<=a)
{
istriangle=false;
}
if(istriangle==false)
{
System.out.print("Not a triangle(不是三角形)");
}
else
{
if(a==b || a==c || b==c)
{
System.out.print("Isosceles(等腰三角形)!");
}
else if(a==b && a==c)
{
System.out.print("Equilateral(等边三角形)");
}
else if(a!=b && a!=c)
{
System.out.print("Sfcalene(一般三角形)");
}
}
}
}
----------------------------------------------------------------------------------------------------------------------