// Computing the Quadratic Equation
import javax.swing.JOptionPane;
//import java.util.*;
public class QuadraticEquation
{
public static void main(String[] args);
//public static void main (String [] args) //throws IOException
{
double A;
double B;
double C;
String numString;
//input integers
JOptionPane.showInputDialog("Enter integer: A");
JOptionPane.showInputDialog("Enter integer: B");
JOptionPane.showInputDialog("Enter integer: C");
//System.out.print("Enter integer A");
//System.out.print("Enter integer B");
//System.out.print("Enter integer C");
double root1= (-B + Math.sqrt( B*B - 4*A*C ) )/ (2*A);
double root2= (-B - Math.sqrt( B*B - 4*A*C ) )/ (2*A);
if(root1>=0)
if(root2>=0)
System.out.print("imaginary root");
else
//root1=root1;
//else
//(int root1="imaginary root");
//if(root2>=0)
System.out.print("imaginary root");
//root2=root2;
// else
// (int root2="imaginary root");
JOptionPane.showMessageDialog(null, ("The roots are: " +root1+ "and" +root2);
//JOptionPane.INFORMATION_MESSAGE); //Line 6
System.exit(0);
}
}
here is the error
---------------- JDK Debug Build ------------------
Compiling C:\Users\Devin\Desktop\QuadraticEquation.java
The current directory is: C:\Users\Devin\Desktop
Command line: "C:\Program Files\Java\jdk1.6.0_16\bin\javac.exe" -deprecation -g -classpath C:\Users\Devin\Desktop "C:\Users\Devin\Desktop\QuadraticEquation.java"
C:\Users\Devin\Desktop\QuadraticEquation.java:44: ')' expected
JOptionPane.showMessageDialog(null, ("The roots are: " +root1+ "and" +root2);
^
just cant figure out what I am doing wrong
Need Help with a java programI keep getting an error when I compile
Page 1 of 1
1 Replies - 637 Views - Last Post: 27 September 2009 - 12:34 PM
Replies To: Need Help with a java program
#2
Re: Need Help with a java program
Posted 27 September 2009 - 12:34 PM
When you make the call to the JOptionPane.showMessageDialog(), you don't need another ( in there, like you have after the null. To fix the error, you can either remove the open parentheses (recommended), or put another close parentheses before the semicolon.
And, for future reference:
And, for future reference:
This post has been edited by Locke: 27 September 2009 - 12:35 PM
Page 1 of 1

New Topic/Question
Reply



MultiQuote



|