Java程序报错,对着课本上敲得报错Lader cannot be resolved to a type
packageMyFirst;importjava.util.Scanner;importjava.util.logging.Logger;publicclasscomp...
package MyFirst;
import java.util.Scanner;
import java.util.logging.Logger;
public class compute {
public static void main(String args[]){
double area=0;
Lader laderOne;这里报错Lader cannot be resolved to a type
laderOne=new Lader();这里也是Lader cannot be resolved to a type
laderOne.seAbove(10);
laderOne.setBottom(20);
laderOne.setHeight(30);
area=laderOne.computeArea();
class Lader{
double above,bottom,height;
Lader(){}
Lader(double a,double b,double c){
above=a;
bottom=b;
height=c;
}
public void setAbove(double a){
above=a;
}
public void setBottom(double b){
bottom=b;
}
public void setHeight(double c){
height=c;
}
double computeArea(){
return(above+bottom)*height/2.0;
}
}
System.out.printf("该面积是:"+area);
}
} 展开
import java.util.Scanner;
import java.util.logging.Logger;
public class compute {
public static void main(String args[]){
double area=0;
Lader laderOne;这里报错Lader cannot be resolved to a type
laderOne=new Lader();这里也是Lader cannot be resolved to a type
laderOne.seAbove(10);
laderOne.setBottom(20);
laderOne.setHeight(30);
area=laderOne.computeArea();
class Lader{
double above,bottom,height;
Lader(){}
Lader(double a,double b,double c){
above=a;
bottom=b;
height=c;
}
public void setAbove(double a){
above=a;
}
public void setBottom(double b){
bottom=b;
}
public void setHeight(double c){
height=c;
}
double computeArea(){
return(above+bottom)*height/2.0;
}
}
System.out.printf("该面积是:"+area);
}
} 展开
2个回答
展开全部
package MyFirst;
public class compute
{
public static void main(String args[])
{
class Lader
{
double above, bottom, height;
Lader()
{
}
@SuppressWarnings("unused")
Lader(double a, double b, double c)
{
above = a;
bottom = b;
height = c;
}
public void setAbove(double a)
{
above = a;
}
public void setBottom(double b)
{
bottom = b;
}
public void setHeight(double c)
{
height = c;
}
double computeArea()
{
return (above + bottom) * height / 2.0;
}
}
double area = 0;
Lader laderOne;
laderOne = new Lader();
laderOne.setAbove(10);
laderOne.setBottom(20);
laderOne.setHeight(30);
area = laderOne.computeArea();
System.out.printf("该面积是:" + area);
}
}
另外,包名建议小写,类名建议首字母大写。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询