2.Derece Denklemi Çözen Program

//MAIN CLASS
 
import javax.swing.JOptionPane;
public class exercise3_1 {
 
public static void main (String[]args){
 
// define a value for the each variables which are a,b,c
 
String aString=JOptionPane.showInputDialog("enter a number for a");
double a=Double.parseDouble(aString);
 
String bString=JOptionPane.showInputDialog("enter a number for b");
double b=Double.parseDouble(bString);
 
String cString=JOptionPane.showInputDialog("enter a number for c");
double c=Double.parseDouble(cString);
 
//compute the discriminant which is going to be necessery to compute the roots of the equation
 
double discriminant=(Math.pow(b,2.0)-4*a*c);
String discriminantString=JOptionPane.showInputDialog("the discriminant is:"+discriminant);
//the discriminant must be positive otherwise,the roots are undefineable.
if (discriminant>=0){
 
double root1= (-b+Math.pow(discriminant,0.5))/(2*a);
double root2= (-b-Math.pow(discriminant,0.5))/(2*a);
 
String output="the roots of the equation is:"+"\nroot1="+root1+"\nand root2="+root2;
JOptionPane.showMessageDialog(null, output);
 
}
 
else{
JOptionPane.showMessageDialog(null, "WRONG NUMBERS!! VALUE OF THE DISCRIMINANT MUST BE POSITIVE!!");
}
 
 
JOptionPane.showMessageDialog(null,"MUSTAFA OGUZ DONMEZ   150713042");
 
 
 
 
 
}
}
 
 
SAAT
 
Facebook beğen
 
 
Bugün 6 ziyaretçi (7 klik) kişi burdaydı!
DFGHJKÖ B Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol