您的位置:首页 > 其它

三角形构成判定(Judge whether 3 side lengths can form a triangle)

2008-04-07 17:27 246 查看

//Judge whether 3 side lengths can be used to form a triangle


import javax.swing.*;




public class ISTriangle ...{


public static void main(String args[])




...{


double l1,l2,l3;


String L1,L2,L3;


boolean guard;


L1=JOptionPane.showInputDialog("Enter the first side length:");


L2=JOptionPane.showInputDialog("Enter the second side length:");


L3=JOptionPane.showInputDialog("Enter the third side length:");




l1=Double.parseDouble(L1);


l2=Double.parseDouble(L2);


l3=Double.parseDouble(L3);




guard=(l1+l2>l3&&l1+l3>l2&&l2+l3>l1);




if (guard)


JOptionPane.showMessageDialog(null, "A triangle can be formed by" +


" the three lengths","Triangle Judgement",JOptionPane.INFORMATION_MESSAGE);


else


JOptionPane.showMessageDialog(null, "A triangle can not be formed by" +


" the three lengths.","Triangle Judgement",JOptionPane.ERROR_MESSAGE);






}




}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐