class ChangFangXing{
创新互联公司是一家专注于成都网站设计、做网站与策划设计,广州网站建设哪家好?创新互联公司做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:广州等地区。广州做网站价格咨询:028-86922220
private int length;
private int width;
public ChangFangXing(){}
public void setLength(int length){
this.length = length;
}
public void setWidth(int width){
this.width = width;
}
/李棚/求周长
public int getZhouChang(){
return (length + width)*2;
}
public int getArea(){
return length * width;
}
}
class ChangFangXingDemo{
public static void main(String[] args){
ChangFangXing s = new ChangFangXing();
s.setLength(5);
s.setWidth(6);
System.out.println("长方形的周棚悉长链扰乎为:"+s.getZhouChang());
System.out.println("长方形的面积为:"+s.getArea());
}
}
import java.text.DecimalFormat;
/**
* Created by ASUS on 2018/迹或灶10/24.
*/
public class test {
static final double p = 3.14;
//圆的姿扮面积为
public static double c(double r){
return p*r*r;
}
//圆的周长
public static double s(double r){
return 2*p*r;
}
public static void main(String [] arge){
System.out.println(fmt(c(2.3d)));
System.out.println(fmt(s(2.3d)));
}
private static String fmt(double rest){
DecimalFormat df = null;
df = new DecimalFormat("###,##0.00"团知);
return df.format(rest);
}
}