JAVA程序要判断输入的3个参数(3条边长)是否能构成一个等腰三角形 程序如何实现 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 判断这三个数中是否有两个相等的,如果没有肯定不行,返回false;如果有,判断这两个相等的数的和是否大于另外一个数,如果大于,则可以,返回true;如果小于等于,则不行,返回false。 public class Test{ public static void main(String[] args) { int a=0,b=0,c=0; try { a=new Integer(args[0]).intValue(); b=new Integer(args[1]).intValue(); c=new Integer(args[2]).intValue(); System.out.println("输入的三边为:"+a+","+b+","+c); System.out.println("是否能构成等腰三角形:"+isIsoscelesTriangle(a,b,c)); } catch (NumberFormatException e) { //输入的参数有非数字格式,比如字符 System.err.println("请输入正确的数字!"); } catch(ArrayIndexOutOfBoundsException e) { //输入的参数不足3个 System.err.println("至少要输入三个数字作为参数!"); } } public static boolean isIsoscelesTriangle(int a,int b,int c) { boolean result=true; if(a!=b) { if(a!=c) { if(b!=c) { result=false; } else { result=(2*b>a)?true:false; } } else { result=(2*a>b)?true:false; } } else { result=(2*a>c)?true:false; } return result; }} Myeclipse9.0 不是自带的,其他的也配置好了,tomcat6.0启动不了 Java 如何获取指定某年 某月 某一周的 第一天 和最后一天? 精简jre 帮一下忙,我想了一天了 关于文件存储的更改与删除,急!!! 帮忙翻译一句话! Class Properties的用法,一个有关配置文件的修改保存的菜鸟问题 敬请高手指教:如何取得数据库服务器的信息?100分。。。 windows xp下怎么安装jdk??(高分求助!!) jdbc中连接池的实现一定要自己写吗?有没现成的类? 这个二维数组定义哪错了?老是报“需要'['” java运行时出错?
{
public static void main(String[] args)
{
int a=0,b=0,c=0;
try
{
a=new Integer(args[0]).intValue();
b=new Integer(args[1]).intValue();
c=new Integer(args[2]).intValue();
System.out.println("输入的三边为:"+a+","+b+","+c);
System.out.println("是否能构成等腰三角形:"+isIsoscelesTriangle(a,b,c));
}
catch (NumberFormatException e)
{
//输入的参数有非数字格式,比如字符
System.err.println("请输入正确的数字!");
}
catch(ArrayIndexOutOfBoundsException e)
{
//输入的参数不足3个
System.err.println("至少要输入三个数字作为参数!");
}
}
public static boolean isIsoscelesTriangle(int a,int b,int c)
{
boolean result=true;
if(a!=b)
{
if(a!=c)
{
if(b!=c)
{
result=false;
}
else
{
result=(2*b>a)?true:false;
}
}
else
{
result=(2*a>b)?true:false;
}
}
else
{
result=(2*a>c)?true:false;
}
return result;
}
}