Thursday, October 15, 2015

Find the highest in three numbers in Jquery

I wrote this program to practice my knowledge about JQuery a very popular javascript framework that makes JavaScript programming much easier and enjoyable. What does the program will do is to ask the user to enter three numbers and then the program determine and display which of the three numbers is the highest. I hope you will find my work useful in learning how to write a program in JQuery.

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.


Program Listing


<html>
<head>
<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
 </head>
 <style>
 h3 {
  font-family:arial;
  color:green;
  }
  </style>
<body>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
 var a,b,c;
 
   a = parseInt(prompt("Enter first number"));
   b = parseInt(prompt("Enter second number"));
   c = parseInt(prompt("Enter third number"));

      if ( a > b && a > c )
         document.write("<h3> First number is largest. That number is " + a + ". </h3>");
      else if ( b > a && b > c )
         document.write("<h3> Second number is largest. That number is " + b + ". </h3>");
      else if ( c > a && c > b )
         document.write("<h3> Third number is largest. That number is " + c + ". </h3>");
      else   
         document.write("<h3> Entered numbers are not distinct. </h3>");
 });
</script>
 </body>
</html>

No comments:

Post a Comment