1. Member
Join Date
Oct 2010
Posts
4
Rep Power
0

Hi, I'm taking a computer science course and I hit a brick wall with my program. Something is wrong and I have no idea how to fix it.

import java.util.*;
import static java.lang.Math.*;
{

Scanner input= new Scanner(System.in);
public static void main(String[] args)
{
//Declare variables
double a=0.0; double b=0.0; double c=0.0;double d=0.0;double e=0.0;
double r1=0.0; double r2=0.0;

a=console.nextDouble();
b=console.nextDouble();
c=console.nextDouble();
//If a=0, make program quit
if (a==0){
System.out.println("The input for a cannot be zero.");
//Else compute d
}else{
b=Math.pow(b,2);
d=(b-4*a*c);
//If d<0 no solution
if (d<0){
System.out.println("The disciminant cannot be less than 0.");
//Else if d=0, one solution.
}else if (d==0){
r1=(-b/2*a);
System.out.println("The single root is "+r1);
//If discriminant fits requirements, find the two roots.
}else{
e=Math.sqrt(d);
r1=((-b+e)/2*a);
r2=((-b-e)/2*e);
System.out.println("The first root is " +r1);
System.out.println("The second root is " +r2);
}
}
}
}

The error messages I receive are:

symbol : variable console
a=console.nextDouble();
^
symbol : variable console
b=console.nextDouble();
^
symbol : variable console
c=console.nextDouble();
^
3 errors

2. You are using a variable called console but never declare it, never initialize it. If this is supposed to be a Scanner variable, you will want to check your notes and texts to see how it is declared and used.

3. Member
Join Date
Oct 2010
Posts
4
Rep Power
0
Alright, I switched input to Scanner, thank you for the help.

Now, I have a different problem where

found : double
required: boolean
if (a=0.0){

found : double
required: boolean
}else if (d=0.0){
^
2 errors

4. There's a big difference between the assignment operator, =, and the equals operator, ==. Does this now make sense?

Luck!

5. Member
Join Date
Oct 2010
Posts
4
Rep Power
0
nm, I got it fixed.

6. Member
Join Date
Oct 2010
Posts
4
Rep Power
0
Thank you for the help!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•