一、输出圆形和矩形的面积
输入代码:
final static double PI=3.1415926;//定义double常量
void s1(int r){//定义整形变量
double s1=r*r*PI;//输入圆面积公式
System.out.println("圆形面积:"+s1);//输出面积
}
void s2(int a,int b){//定义整型变量
float s2=a*b;//输入矩形面积公式
System.out.println("矩形面积:"+s2);//输出面积
}
class shap{//创建shape类
}public class shap1 extends Shape {
public static void main(String[] args) {
Shape a=new Shape();//创建shape类对