为了账号安全,请及时绑定邮箱和手机立即绑定

修复程序上的错误以调用 Java 中的方法

修复程序上的错误以调用 Java 中的方法

绝地无双 2023-03-23 16:56:19
以下程序包含 9 个错误。更正错误并提交程序的工作版本。该程序的更正版本应产生以下输出:x = 10.01 and y = 8.0 x = 10.01 and y = 867.5309 来自 main 的值为:867.5309 z = 5我已经对此做了一些更改,但我可以弄清楚为什么没有调用 x 和 y。public class Oops3 {    public static void main(String[] args) {        double y = 867.5309;        double x = 10.01;        printer(double x, double y);        printer(x);        printer(y);        System.out.println("z = " + z);}public static void printer(double x, double y) {    int z = 5;    System.out.println("x = " + double x + " and y = " + double y);    System.out.println("The value from main is: " + y);}}
查看完整描述

3 回答

?
温温酱

TA贡献1752条经验 获得超4个赞

试试这个:(不确定你已经做了多少改变)


public class Oops3 {


public static void printer(double x, double y) {

        System.out.println("x = " +  x + " and y = " +  y);

        System.out.println("The value from main is: " + y);}


public static void main(String[] args) {


            int z = 5;

            double y = 867.5309;

            double x = 10.01;

            System.out.println("x= " + x + " and y = 8.0");

            printer( x,y);

            System.out.println("z = " + z);


}}


查看完整回答
反对 回复 2023-03-23
?
呼如林

TA贡献1798条经验 获得超3个赞

以下是您要查找的工作代码


public class Oops3 

{

public static void printer(double x, double y, int z) {

    System.out.println("x = " + x + " and y = " + y);

System.out.println("The value from main is: " + y);

    System.out.println("z = " + z);

}


public static void main(String[] args) {

    Oops3 O=new Oops3();

    double y = 867.5309;

    double x = 10.01;

int z = 5;

    O.printer(x, y, z);

}

}


查看完整回答
反对 回复 2023-03-23
?
MM们

TA贡献1886条经验 获得超2个赞

这段代码对我有用


public class Oops3 {

public static void main(String [] args) {

    Oops3 i = new Oops3();

    double bubble = 867.5309;

    double x = 10.01;

    double y = 8.0;

    int z = 5;

    i.printer(x, y);

    i.printer(x, bubble);

    System.out.println("The value from main is: " + bubble);

    System.out.println("z = " + z);

}


public static void printer(double x, double y) {

    System.out.println("x = " +  x + " and y = " + y);

}

}


查看完整回答
反对 回复 2023-03-23
  • 3 回答
  • 0 关注
  • 153 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号