以下程序包含9个错误。更正错误并提交程序的有效版本。程序的更正版本应产生以下输出:
x = 10.01和y = 8.0 x = 10.01和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);
}
}
答案 0 :(得分:0)
尝试以下操作:(不确定您已经进行了多少更改)
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);
}}
答案 1 :(得分:0)
以下是您要查找的工作代码
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);
}
}
答案 2 :(得分:0)
这段代码对我有用
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);
}
}