java 我是新手~ 请问为什么CMD提示找不到符号呢?
publicclassQuadratic{publicstaticvoidmain(String[]args){System.out.println("1)Enterco...
public class Quadratic
{
public static void main(String[] args)
{
System.out.println("1) Enter coefficients");
System.out.println("2) Solve for given x");
System.out.println("3) Find roots");
System.out.println("4)Quit");
System.out.println("Please enter option:");
int option;
option = StdIn.readInt();
switch(option)
{
case 1:
System.out.println("Please enter a:");
int a = StdIn.readInt();
System.out.println("Please enter b:");
int b = StdIn.readInt();
System.out.println("Please enter c:");
int c = StdIn.readInt();
break;
case 2:
System.out.println("Please enter x:");
int x = StdIn.readInt();
int m = Math.pow(d,2);
int n = m + b*x + c ;
break;
case 3:
if(b*b - 4*a*c < 0)
{
System.out.println("Not real roots exist.");
}
else if (b*b - 4*a*c >=o)
{
double num = -b/(2.0*a);
double root = Math.sqrt(b*b-4*a*c)/(2.0*a);
double x1 = number - root;
double x2 = number + root;
System.out.println("Real roots of"+ x1 + "and" + x2 + "exist.");
}
break;
case 4:
System.out.println("Exit.");
}
}
}
这是一个解一元二次方程的题,我还没有写完。。。
[zy03443@unnc-cslinux ex1]$ javac Quadratic.java
Quadratic.java:27: cannot find symbol
symbol : variable d
location: class Quadratic
int m = Math.pow(d,2);
^
Quadratic.java:36: cannot find symbol
symbol : variable o
location: class Quadratic
else if (b*b - 4*a*c >=o)
^
Quadratic.java:40: cannot find symbol
symbol : variable number
location: class Quadratic
double x1 = number - root;
^
Quadratic.java:41: cannot find symbol
symbol : variable number
location: class Quadratic
double x2 = number + root;
^
Quadratic.java:41: incompatible types
found : <nulltype>
required: double
double x2 = number + root;
^
5 errors
这个是错误提示。。。
请高手来解答,万分感谢!
问题还是没有解决。。。那个d是我写错了,应该是x。。。谢谢大家。。 展开
{
public static void main(String[] args)
{
System.out.println("1) Enter coefficients");
System.out.println("2) Solve for given x");
System.out.println("3) Find roots");
System.out.println("4)Quit");
System.out.println("Please enter option:");
int option;
option = StdIn.readInt();
switch(option)
{
case 1:
System.out.println("Please enter a:");
int a = StdIn.readInt();
System.out.println("Please enter b:");
int b = StdIn.readInt();
System.out.println("Please enter c:");
int c = StdIn.readInt();
break;
case 2:
System.out.println("Please enter x:");
int x = StdIn.readInt();
int m = Math.pow(d,2);
int n = m + b*x + c ;
break;
case 3:
if(b*b - 4*a*c < 0)
{
System.out.println("Not real roots exist.");
}
else if (b*b - 4*a*c >=o)
{
double num = -b/(2.0*a);
double root = Math.sqrt(b*b-4*a*c)/(2.0*a);
double x1 = number - root;
double x2 = number + root;
System.out.println("Real roots of"+ x1 + "and" + x2 + "exist.");
}
break;
case 4:
System.out.println("Exit.");
}
}
}
这是一个解一元二次方程的题,我还没有写完。。。
[zy03443@unnc-cslinux ex1]$ javac Quadratic.java
Quadratic.java:27: cannot find symbol
symbol : variable d
location: class Quadratic
int m = Math.pow(d,2);
^
Quadratic.java:36: cannot find symbol
symbol : variable o
location: class Quadratic
else if (b*b - 4*a*c >=o)
^
Quadratic.java:40: cannot find symbol
symbol : variable number
location: class Quadratic
double x1 = number - root;
^
Quadratic.java:41: cannot find symbol
symbol : variable number
location: class Quadratic
double x2 = number + root;
^
Quadratic.java:41: incompatible types
found : <nulltype>
required: double
double x2 = number + root;
^
5 errors
这个是错误提示。。。
请高手来解答,万分感谢!
问题还是没有解决。。。那个d是我写错了,应该是x。。。谢谢大家。。 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询