大鹅努力学编程 2023-03-31 10:56 采纳率: 85.7%
浏览 29
已结题

error: cannot find symbol

import java.util.Scanner;
class Rect{
    double l,h,z;
    public Rect(double l,double h,double z){
        this.l=l;
        this.h=h;
        this.z=z;
    }
    //在父类Rect中,定义求底面周长的方法length( )和底面积的方法area( )。
    public double length(){
        return 2*(l+h);
    }
    public double area(){
        return l*h;
    }
}
//定义父类Rect的子类立方体类Cubic,计算立方体的表面积和体积。其中表面积area( )重写父类的方法。
class Cubic extends Rect{
    public Cubic(double l,double h,double z){
        super(l,h,z);
    }
    public double v(){
        return super.area()*z;
    } 
    public double area(){
        return length()*z+2*super.area();
    }
}
//定义父类Rect的子类四棱锥类Pyramid,计算四棱锥的表面积和体积。其中表面积area( )重写父类的方法。
class Pyramid extends Rect{
    public Pyramid(double l,double h,double z){
        super(l,h,z);
    }
    public double area(){
        return (l*h+(Math.sqrt(z*z+(h/2)*(h/2))*l)+(Math.sqrt(z*z+(l/2)*(l/2))*h));
    }
    public double v(){
        return super.area()*z/3;
    }
}
public class Main{
    public static void main(String[] args){
        //在主程序中,输入立体图形的长(l)、宽(h)、高(z)数据,分别输出长方体的表面积、体积、四棱锥的表面积和体积
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            double l,h,z;
            l=sc.nextdouble();
            h=sc.nextdouble();
            z=sc.nextdouble();
            if(l<=0||h<=0||z<=0)
            {
                System.out.println("0.00 0.00 0.00 0.00");
            }
            else{
                Cubic Cubic=new Cubic(l,h,z);
                Pyramid Pyramid=new Pyramid(l,h,z);
                System.out.printf("%.2f %.2f %.2f %.2f\n",Cubic.area(),Cubic.v(),Pyramid.area(),Pyramid.v());
            }
        }
    }
}
//Main.java:47: error: cannot find symbol
//            l=sc.nextdouble();
//                ^
//  symbol:   method nextdouble()
//  location: variable sc of type Scanner
//Main.java:48: error: cannot find symbol
//            h=sc.nextdouble();
//                ^
//  symbol:   method nextdouble()
//  location: variable sc of type Scanner
//Main.java:49: error: cannot find symbol
//            z=sc.nextdouble();
//                ^
//  symbol:   method nextdouble()
//  location: variable sc of type Scanner
3 errors
  • 写回答

1条回答 默认 最新

  • threenewbee 2023-03-31 11:00
    关注

    nextdouble();
    ->
    nextDouble();
    大写!!!!!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月8日
  • 已采纳回答 3月31日
  • 创建了问题 3月31日

悬赏问题

  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?