Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

# New to Java Need Help

### #1 MkLoe Posted 01 May 2007 - 06:52 PM

MkLoe

Visiting Staff

• Member
• 650 posts
I am new to java and need some help with the quadratic formula here is what I have:

import javax.swing.JOptionPane;

public class Math {

public static void main (String args[]) {

String strA;
String strB;
String strC;

//allows decimals

//This asks what you want to be entered
strA = JOptionPane.showInputDialog("Enter A");
strB = JOptionPane.showInputDialog("Enter B");
strC = JOptionPane.showInputDialog("Enter C");

//This tell java to convert words into number
dblA = Double.parseDouble(strA);
dblB = Double.parseDouble(strB);
dblC = Double.parseDouble(strC);

//Performs Operation
dblM = (dblB * dblB) - (4 * dblA * dblC);
dblP = (- (dblB)) + (Math.sqrt(dblM) );
dblAnswerOne = (dblP / (2 * dblA));

//will have answer Two soon but want to get one down first

System.exit(0);

}

}

Here is my compiler :

C:\Documents and Settings\Michael\Desktop\Math.java:28: cannot find symbol
symbol : method sqrt(double)
location: class Math
dblP = (- (dblB)) + (Math.sqrt(dblM) );
^
C:\Documents and Settings\Michael\Desktop\Math.java:28: operator + cannot be applied to double,Math.sqrt
dblP = (- (dblB)) + (Math.sqrt(dblM) );
^
C:\Documents and Settings\Michael\Desktop\Math.java:28: incompatible types
found : <nulltype>
required: double
dblP = (- (dblB)) + (Math.sqrt(dblM) );
^
3 errors

Tool completed with exit code 1

Any help is appreciated
• 0

### #2 MkLoe Posted 01 May 2007 - 07:14 PM

MkLoe

Visiting Staff

• Topic Starter
• Member
• 650 posts
I got it anyone intrested here it is:

//Created by MkLoe
//May 1, 2007

import javax.swing.JOptionPane;
import java.lang.Math;

public static void main (String args[]) {

String strA;
String strB;
String strC;

//allows decimals

//This asks what you want to be entered
strA = JOptionPane.showInputDialog("Enter A");
strB = JOptionPane.showInputDialog("Enter B");
strC = JOptionPane.showInputDialog("Enter C");

//This tell java to convert words into number
dblA = Double.parseDouble(strA);
dblB = Double.parseDouble(strB);
dblC = Double.parseDouble(strC);

//Performs Operation
dblM = (dblB * dblB) - (4 * dblA * dblC);
dblP = (- (dblB)) + (Math.sqrt(dblM) );
dblAnswerOne = (dblP / (2 * dblA));

dblY = (dblB * dblB) - (4 * dblA * dblC);
dblX = (- (dblB)) - (Math.sqrt(dblY) );
dblAnswerTwo = (dblX / (2 * dblA));

System.exit(0);

}

}

Edited by MkLoe, 01 May 2007 - 07:15 PM.

• 0

### Similar Topics

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users