Need Help with a java program

I keep getting an error when I compile

Page 1 of 1

1 Replies - 637 Views - Last Post: 27 September 2009 - 12:34 PM Rate Topic: -----

#1 bearclawcurley   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-September 09

Need Help with a java program

Posted 27 September 2009 - 12:33 PM

// 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

Is This A Good Question/Topic? 0
  • +

Replies To: Need Help with a java program

#2 Locke   User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 552
  • View blog
  • Posts: 5,624
  • Joined: 20-March 08

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: :code:

This post has been edited by Locke: 27 September 2009 - 12:35 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1