package com.hanqi.test;

public class sanjiaoxing {
private double a;
private double b;
private double c;
public double getA() {
return a;
}
public void setA(double a) {
this.a = a;
}
public double getB() {
return b;
}
public void setB(double b) {
this.b = b;
}
public double getC() {
return c;
}
public void setC(double c) {
this.c = c;
} public double getZhouchang()
{
return a+b+c;
} }

  

package com.hanqi.test;

public class Test07 {

    public static void main(String[] args) {
sanjiaoxing sjx=new sanjiaoxing();
sjx.setA();
sjx.setB();
sjx.setC();
System.out.println("三边分别是10,20,30的周长是:"+sjx.getZhouchang()); } }

创建一个三角形类,成员变量三边,方法求周长,创建类主类A来测试它-LMLPHP

04-30 02:58