package a; import java.nio.charset.MalformedInputException; public class Sanjiaoxing { private double a,b,c; // public Sanjiaoxing(double a, double b, double c) { // super(); // this.a = a; // this.b = b; // this.c = c; // } public void zhouchang(double a,double b,double c) { //Math.abs(a-b)取绝对值 if(a>0&&b>0&&c>0&&(a+b)>c&&Math.abs(a-b)<c) { System.out.println("周长为:"+(a+b+c)); } else { System.out.println("参数错误"); } } public static void main(String[] args) { Sanjiaoxing sanjiao=new Sanjiaoxing(); sanjiao.zhouchang(3, 4, 5); } }