<HTML>
<HEAD>
<TITLE>Persamaan kuadrat</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
function det(a,b,c)
{
var d = (b*b)-(4*a*c);
return(d);
}
var a = parseFloat(prompt("Masukan Nilai A =\n"));
var b = parseFloat(prompt("Masukan Nilai B =\n"));
var c = parseFloat(prompt("Masukan Nilai C =\n"));
var deter = det(a,b,c);
document.write("Nilai Determinannya = " +deter+"<BR>");
document.write("<BR>");
document.write("<BR>");
if (deter>0)
{
var x1 = (-b - Math.sqrt(deter))/(2*a);
var x2 = (-b + Math.sqrt(deter))/(2*a);
document.write("Nilai x1 = " +x1+ "<BR>");
document.write("Nilai x2 = " +x2+ "<BR>");
document.write("<BR>");
document.write("<BR>");
document.write("Akar-akarnya Berbeda");
} else
if (deter==0)
{
var x1 = (-b - Math.sqrt(deter))/(2*a);
var x2 = (-b + Math.sqrt(deter))/(2*a);
document.write("Nilai x1 = " +x1+ "<BR>");
document.write("Nilai x2 = " +x2+ "<BR>");
document.write("<BR>");
document.write("<BR>");
document.write("Akar-akarnya Sama");
} else
if (deter<0)
{
document.write("Akar-akarnya Imaginer");
}
</SCRIPT>
</BODY>
</HTML>
No comments:
Post a Comment