Selasa, 11 Maret 2014

PERSAMAAN KUADRAT

Yanng Posting Unknown di 09.11
<html>
<head>
<title>PERSAMAAN KUADRAT</title>
</head>

<body bgcolor=pink>
<script type=text/javascript>
function det(a,b,c)
{
var d = (b*b)-(4*a*c);
return(d);
}
var a = parseFloat(prompt("Masukan Nilai A  \n : ax2 + bx + c = 0"));
var b = parseFloat(prompt("Masukan Nilai B  \n : ax2 + bx + c = 0"));
var c = parseFloat(prompt("Masukan Nilai C  \n : ax2 + bx + c = 0"));
var deter = det(a,b,c);

document.write("Nilai Determinan = " +deter+"<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("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("Akar-akarnya Sama");
} else

if (deter<0)
{
document.write("Akar-akarnya Imaginer");
}
 

</script>
</body>
</html>

0 komentar:

Posting Komentar

 

SI MATA SEMUT Template by Ipietoon Blogger Template | Gift Idea