Results 1 to 5 of 5
- 07-07-2011, 01:43 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 6
- Rep Power
- 0
Write a java program to display a gui of quadratic equation
package Almigthy;
import javax.swing.*;
/**
*
* @author YUSBETH
*/
public class quadraticEquation {
private static Object String;
private static String txt;
public static void main(String[]args ){
String = null;
int a, b, c;
txt =JOptionPane.showInputDialog("Enter a");
a=Integer.parseInt(txt);
txt =JOptionPane.showInputDialog("Enter b");
b=Integer.parseInt(txt);
txt =JOptionPane.showInputDialog("Enter c");
c=Integer.parseInt(txt);
double D=descriminant(a,b,c);
if (D<0){
System.out.println("Complex Roots");
}
else if(D==0){
double X1=(-b)/(2*a);
double X2=X1;
System.out.println("Equal Roots" + X1);
}
else{
double X1=((-b)+ Math.sqrt(D))/(2*a);
double X2=((-b)- Math.sqrt(D))/(2*a);
System.out.println("Roots" + X1 + "and " + X2);
}
}
public static double descriminant(int a, int b, int c){
double Quad=(b*b)-(4*a*c);
return Quad;
}
}
- 07-07-2011, 02:04 AM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,604
- Rep Power
- 5
Do you have a question associated with this? (and please use the code tags)
- 07-07-2011, 02:35 AM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
[code]
YOUR CODE HERE
[/code]
Is how you use code tags.
- 07-08-2011, 06:20 AM #4
Member
- Join Date
- Jul 2011
- Posts
- 6
- Rep Power
- 0
sorry, i did understand your question, (sunde887) , (dowhile)
- 07-08-2011, 06:35 AM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
What don't you understand? doWhile was asking what is your specific question, as it stands now, this is simply a code dump. Provide an exact question for us to help you with. He also suggested you use code tags when posting code. My post shows how they are used.
Similar Threads
-
Quadratic Equation Code Question
By meangrant in forum New To JavaReplies: 5Last Post: 10-31-2010, 03:22 AM -
quadratic equation, problems that i can't solve
By kourai in forum New To JavaReplies: 2Last Post: 10-14-2010, 01:31 PM -
quadratic equation whith Rational class
By adamrain in forum New To JavaReplies: 8Last Post: 12-22-2009, 05:35 PM -
Quadratic Equation
By jpnym15 in forum New To JavaReplies: 4Last Post: 11-12-2008, 03:29 AM -
Help with quadratic equation in java
By paul in forum New To JavaReplies: 1Last Post: 07-25-2007, 08:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks