<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css" />
<style type="text/css"></style>
<script src="scripts.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
var valeure1;
var valeure2;
var valeure3;

function racines()
{
val1 = document.polynome.valeure1.value;
val2 = document.polynome.valeure2.value;
val3 = document.polynome.valeure3.value;	
var delta = Math.pow(val2,2)-4*val1*val3;

if (delta < 0) {
document.polynome.RESULTAT.value ="Les racines sont des nombres imaginaires.";
document.polynome.RESULTAT1.value = " ";
document.polynome.RESULTAT2.value = " ";
document.polynome.RESULTAT0.value = " ";
}

else if (val1==0 && val2==0 && val3==0) {
document.polynome.RESULTAT.value ="Entrer les coefficients ..";
document.polynome.RESULTAT1.value = " ";
document.polynome.RESULTAT2.value = " ";
document.polynome.RESULTAT0.value = " ";
}

else if (val1==0){
var result10 = -val3/val2;
document.polynome.RESULTAT.value ="Une racine réelle :";
document.polynome.RESULTAT1.value = result10;
document.polynome.RESULTAT2.value = " ";
document.polynome.RESULTAT0.value = (result10 >0)? document.polynome.RESULTAT0.value 
= "P = (x - " + result10 + ")(x - " + result10 + ")": 
document.polynome.RESULTAT0.value 
= "P = (x + " + Math.abs(result10) + ")(x + " + Math.abs(result10) + ")";
}

else
{
var result1 = - val2/2/val1 + Math.pow(delta,0.5)/2/val1;
result1 = Math.round(result1*100)/100 ;
var result2=  - val2/2/val1 - Math.pow(delta,0.5)/2/val1;
result2 = Math.round(result2*100)/100 ;

document.polynome.RESULTAT.value ="Les racines sont réelles :";
document.polynome.RESULTAT1.value = result1;
document.polynome.RESULTAT2.value = result2;

if(result1>0 && result2<0){
result2 = -result2;
document.polynome.RESULTAT0.value = "P = (x - " + result1 + ")(x + " + result2 +")";
}
else if(result1<0 &&result2>0){
document.polynome.RESULTAT0.value = "P = (x " + result1 + ")(x - " + result2 + ")";
}

else if(result1>0 && result2>0){
document.polynome.RESULTAT0.value = "P = (x - " + result1 + ")(x - " + result2 + ")";
}
else if(result1<0 && result2<0){
result1 = -result1;
result2 = -result2;
document.polynome.RESULTAT0.value = "P = (x + " + result1 + ")(x + " + result2 +")";
}
else{
document.polynome.RESULTAT0.value = " ";
}

}
}
// -->
</script>
</head>

<body>
<center>

<form name ="polynome"> 

<table border = "" width = "400" border = "0">

<tr><td colspan="2" class = "centre" width = "400" ><h1> 
P = ax<sup>2</sup> + bx + c </h1></td></tr>
<br />

<tr><td>
<font color = "blue" size = "+1">Entrer le 1er coefficient: a </font></TD><TD>
<input style="background-color:#FFE4E1; color:black; TYPE="txt" SIZE="18" VALUE="" 
NAME="valeure1">
</td></tr>

<tr><td>
<font color = "red" size = "+1">Entrer le 2ème coefficient: b </font></TD>
<TD><input style="background-color:#AFEEEE; color:black; TYPE="txt" SIZE="18" 
VALUE="" NAME="valeure2"></td></tr>


<tr><td>
<font color = "green"" size = "+1">Entrer le 3ème coefficient: c </td><TD>
<input style="background-color:#FFEFD5; color:black TYPE="txt" SIZE="18" VALUE="" 
NAME="valeure3">
</td></tr>

<br /><br />

<tr><td class = "centre" colspan="2"><input class = "centre" TYPE="button" 
SIZE ="15" VALUE ="Extraire les racines" NAME="" onClick = "racines();" 
style = "color: blue; background-color:#AFEEEE; font-size: 15; font-family:Bookman old 
style; font-weight:bold;"> 
</TD></tr>

<tr><td colspan="2">
<input align = "center" style="background-color:#E6E6FA; color:red; font-size:15"; 
TYPE="txt" SIZE="45" NAME="RESULTAT" VALUE="0" color = "red"></td><TD>
</TD></tr>

<tr><td colspan="2">
<input align = "center" style="background-color:#E6E6FA; color:black; font-size:15"; 
TYPE="txt" SIZE="45" NAME="RESULTAT1" VALUE="0" color = "red"></td><TD>
</TD></tr>

<tr><td colspan="2">
<input align = "center" style="background-color:#FCF4F4; color:black; font-size:15"; 
TYPE="txt" SIZE="45" NAME="RESULTAT2" VALUE="0" color = "red"></td><TD>
</TD>
</tr>

<tr><td colspan="2">
<input align = "center" style="background-color:#AFEEEE; color:black; font-size:15"; 
TYPE="txt" SIZE="45" NAME="RESULTAT0" VALUE="0" color = "red"></td><TD>
</TD>
</tr>


</table>
</form>
<a href="polynomial_source.html" target = "file2">code source</a>
</center>
</body>
</html>