Showing posts with label Area of Triangle in JavaScript. Show all posts
Showing posts with label Area of Triangle in JavaScript. Show all posts

Friday, October 23, 2015

Area of Triangle in JavaScript

A sample program that I wrote in JavaScript that will calculate the area of the triangle based on the values being provided by the user.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.


Sample Program Output


Program Listing

<html>
<head>
  <title>Area of Triangle</title>
</head>
<style>
h3 {
   font-family:arial;
   };
</style>
<body>
  <script>
    
var base = parseInt(prompt("Enter width of Triangle : "));
var height = parseInt(prompt("Enter height of Triangle : "));
   
    var solving_triangle = (base * height)/2;
 
document.write("<br>");
document.write("<h3> Area of Triangle</h3>");
document.write("<font face='arial' size='3'>")
    document.write(" The Width of Triangle is " + base + ".</font><br>");
document.write("<font face='arial' size='3'>")
    document.write(" The Height of Triangle is " + height + ".</font><br><br>");
    document.write("<font face='arial' size='3'>")
    document.write(" The Area of Triangle is " + solving_triangle + ".</font>");
document.write("<h3> End of Program </h3>");
</script>
</body>
</html>