Minggu, 30 Januari 2011

Javascript menghitung Luas dan Keliling segitiga siku-siku

<html>
<head>
</head>
<body>
<script language="Javascript">

var x=prompt("Program sederhana untuk menghitung luas dan keliling segitiga silu-siku" + 'n' + "Ketik luas atau keliling: ");

if(x=="luas")
{
a=parseInt(prompt("Alas: "));
t=parseInt(prompt("Tinggi: "));
l=(0.5*a*t);
document.write("Alas: ",a);
document.write("<br>");
document.write("Tinggi: ",t);
document.write("<br>");
document.write("Luas:1/2 x Alas x Tinggi: ",l);
}
else if(x=="keliling")
{
a=parseInt(prompt("Sisi a: "));
b=parseInt(prompt("Sisi b: "));
c=parseInt(prompt("Sisi c: "));
k= a+b+c;
document.write("a: ",a);
document.write("<br>");
document.write("b: ",b);
document.write("<br>");
document.write("c: ",c);
document.write("<br>");
document.write("Keliling: ",k);
}
else
{
document.write("Tidak ada yg dihitung");
}
</script>
</body>
</html>

Download link: ziddu.com

0 komentar:

Poskan Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Sweet Tomatoes Printable Coupons