日期:2014-05-20 浏览次数:20800 次
public class d { int aaa = 3; public static void main(String args[]) { Cylinder obj = new Cylinder(); obj.area(); } private class Cylinder { double radius; int height; double pi=3.14; void area() { System.out.println("圆柱体面积="+(pi*radius*radius) * aaa); } void volume() { System.out.println("圆柱体体积="+(((pi*radius*radius))*height)); } } }
package ceshi; public class d { int aaa = 3; public static void main(String args[]) { Cylinder obj = new Cylinder(); obj.area(); } } class Cylinder { double radius; int height; double pi = 3.14; void area() { double aaa = 0; //你没有定义aaa 需要自己定义并给所需要的值 System.out.println("圆柱体面积=" + (pi * radius * radius) * aaa); } void volume() { System.out.println("圆柱体体积=" + (((pi * radius * radius)) * height)); } }
------解决方案--------------------
public class d
{
int aaa = 3;
public static void main(String args[])
{
Cylinder obj = new Cylinder();
obj.area(aaa);
}
public class Cylinder
{
double radius;
int height;
double pi=3.14;
void area(int aaa)
{
System.out.println("圆柱体面积="+(pi*radius*radius) * aaa);
}
void volume()
{
System.out.println("圆柱体体积="+(((pi*radius*radius))*height));
}
}
}
------解决方案--------------------
public class Test { public static void main(String args[]) { Cylinder obj = new Cylinder(); obj.area(10.0,5); } } class Cylinder { double pi=3.14; void area(double radius,int height) { //不过你的圆柱体表面积计算公式好像有问题吧,应该是(2π*R*R+2π*R*H) System.out.println("圆柱体面积="+(pi*radius*radius) ); } void volume(double radius,int height) { System.out.println("圆柱体体积="+(((pi*radius*radius))*height)); } } class Cylinder前不加private
------解决方案--------------------
没仔细看 看样子应该是2楼那样 传一个aaa 过去 2楼正解
------解决方案--------------------
aaa 应该是作为参数传过去的。同意2楼。
------解决方案--------------------
看迷糊了
------解决方案--------------------