Monday, November 16, 2015

Subject Grade Solver in JavaScript

A program that I wrote that will compute the prelim, midterm and endterm grade in a particular subject using JavaScript this program also give a remarks whether the subject is PASSED or FAILED.

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>
<style>
body,p {

  font-family:arial;
  font-size:16px;
  font-weight:bolder;
 }

    .container {
        width: 350px;
        clear: both;
    }
    .container input {
        width: 100%;
        clear: both;
    }

    </style>
<div class="container">
<body>
<h3> Subject Grade Solver </h3>
<br/>Subject

<input type="text" id="subject" name="subject">
<br>
<br/> Prelim Grade
<input type="text" id="prelim" name="prelim">
<br>
<br/> Midterm Grade
<input type="text" id="midterm" name="midterm">
<br>
<br>Endterm Grade
<input type="text" id="endterm" name="endterm">
<br>
<br>
<button onclick="compute_grade()">Compute Grade</button>
<br><br>
<p id="demo"></p>
<p id="demo2"></p>
<p id="demo3"></p>
</div>
<script>
  function compute_grade() {
    var  subject = document.getElementById("subject").value;
var  prelim = document.getElementById("prelim").value;
var  midterm = document.getElementById("midterm").value;
var  endterm = document.getElementById("endterm").value;
     solve_prelim = parseFloat(prelim) * 0.20;
solve_midterm = parseFloat(midterm) * 0.30;
solve_endterm = parseFloat(endterm) * 0.50;
   
      final_grade  = (solve_prelim + solve_midterm + solve_endterm);
 
 if (final_grade >= 75) {
    remarks = "PASSED";
    results = "In your subject " +subject +"."
         results2= " Your final grade is " + final_grade.toFixed(0) + ".";
results3 = " You " + remarks + " the subject."; 
 
}
else {
 remarks="FAILED";
 results = "In your subject " +subject + ".";
 results2= " Your final grade is " + final_grade.toFixed(0) + ".";
 results3="You " + remarks + " the subject."; 
 
 } 
   
          document.getElementById("demo").innerHTML = results;
 document.getElementById("demo2").innerHTML = results2;
 document.getElementById("demo3").innerHTML = results3;
  }
</script>
</body>

</html>


Simple Interest Rate Calculator in JavaScript

A sample program that I wrote the will compute the interest rate of a loan I called this program simple interest rate calculator written in JavaScript.

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>
<style>
body,p {

  font-family:arial;
  font-size:16px;
  font-weight:bolder;
 }

    .container {
        width: 350px;
        clear: both;
    }
    .container input {
        width: 100%;
        clear: both;
    }

    </style>
<div class="container">
<body>
<h3> Simple Interest Calculator </h3>
<br/>Principal (P): Php
<input type="text" id="principal" name="principal">
<br>
<br/> Rate (R):
<input type="text" id="rate" name="rate">
<br>
<br/> Time (t):
<input type="text" id="time" name="time">
<br>
<br>
<button onclick="compute_interest()">Compute Interest</button>
<br><br>
<p id="demo"></p>

</div>
<script>
function Commas(n) {
    var parts=n.toString().split(".")
    return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (parts[1] ? "." + parts[1] : "");
}
  function compute_interest() {
    var  principal = document.getElementById("principal").value;
var  rate = document.getElementById("rate").value;
var  time = document.getElementById("time").value;
     rate2 = parseFloat(rate)/100;
amount_interest = parseFloat(principal) * (1+ (parseFloat(rate2)*time));
     
amt =amount_interest.toFixed(2);
display = Commas(amt);
results ="Amount to be paid is Php " + display+".";
     
      document.getElementById("demo").innerHTML = results;
  }
</script>
</body>

</html>

Payroll System in JavaScript

A simple program that I wrote in JavaScript to solve the salary of an employee in a company the code is very simple I'm using HTML forms to gather input values from 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>
<style>
body,p {

  font-family:arial;
  font-size:16px;
  font-weight:bolder;
 }
 
    .container {
        width: 500px;
        clear: both;
    }
    .container input {
        width: 100%;
        clear: both;
    }

    </style>
<div class="container">
<body>
<h3> Payroll System </h3>
<br/>Employee's Name
<input type="text" id="emp_name" name="emp_name">
<br>
<br/> Daily Rate
<input type="text" id="daily_rate" name="daily_rate">
<br>
<br/> Number of Days Work
<input type="text" id="no_days_work" name="no_days_work">
<br>
<br>
<button onclick="solve_salary()">Solve Salary</button>
<br><br>
<p id="demo"></p>
<p id="demo2"></p>
</div>
<script>
  function solve_salary() {
    var  emp_name = document.getElementById("emp_name").value;
var  daily_rate = document.getElementById("daily_rate").value;
var  no_days_work = document.getElementById("no_days_work").value;
     gross_pay= parseFloat(daily_rate) * no_days_work;
 
      results = "Employee's Name :     " + emp_name + ".";
 results2 ="Basic Salary  : Php " + gross_pay.toFixed(2)+".";
     
      document.getElementById("demo").innerHTML = results;
 document.getElementById("demo2").innerHTML = results2;
 
  }
</script>
</body>
</html>

Positive and Negative Number Checker in JavaScript

A simple program that I wrote using JavaScript and HTML forms to accept a number from the user and then the program will check and determine if the given number is positive or number.

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>
<style>
body,p {

  font-family:arial;
  font-size:16px;
 }
</style> 
<body>
<h3> Positive and Negative Number Checker </h3>
<br/>Enter a Number 
<input type="text" id="num_value" name="num_value" size="5">
<br><br>
<button onclick="check_number()">Check Number</button>
<br><br>
<p id="demo"></p>
<script>
  function check_number() {
    var  num_value= document.getElementById("num_value").value;
   
    if (num_value >=0 ) {
  result =  num_value + " is a Positive Number.";
 }
else  {
   result =  num_value +" is a Negative Number.";
}
   
    document.getElementById("demo").innerHTML = result;
  }
</script>
</body>
</html>

Thursday, November 12, 2015

Simple Form Validation in JavaScript

A simple form validation that I wrote in JavaScript to check if the text fields has already a value prior it will send the data in the server for processing like using ASP.NET, ASP, PHP, PERL to process the given data by the user. The code is very simple for beginners that are new in HTML and JavaScript.

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>Form Validation</title>
<style type="text/css">
p,body {
  font-family:arial;
  font-size:20px;
 }

</style>
<script type="text/javascript">

function validate( form )
{
var email_format = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;  
var phone_format = /^\+?([0-9]{2})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;  

  var fname=form.FirstName.value;
  var lname=form.LastName.value;
  var email=form.Email.value;
  var phone=form.Phone.value; 
  var address=form.Address.value;

var error=document.getElementById('error');

// checking for first name
if(fname==""){
error.innerHTML="* Please enter your first name.";
document.getElementById('FirstName').focus();
return false;

// checking for last name

 if (lname==""){
error.innerHTML="* Please enter your last name.";
document.getElementById('LastName').focus();
return false;

// checking for email address


  if (email==""){
error.innerHTML="* Please enter a valid email address.";
document.getElementById('Email').focus();
return false;
}

 if (!email.match(email_format) ) {
       error.innerHTML="* Please enter a valid email address.";
       document.getElementById('Email').focus();
        return false;
    }

if (!phone.match(phone_format) ) {
       error.innerHTML="* Please enter a valid telephone number.";
       document.getElementById('Email').focus();
        return false;
    } 

// checking for address

 if (address==""){
    error.innerHTML="* Please enter your home address.";
    document.getElementById('Address').focus();
    return false;
   }

}
</script>
</head>

<body>
Form Validation
<form name="form" method="post" onsubmit="return validate(this);">

<table cellspacing="6" cellpadding="4" border="0">
        <tr>
          <td align="right">
            First Name
          </td>
          <td>
            <input type="text" name="FirstName" id="FirstName" />
          </td>
        </tr>
        <tr>
          <td align="right">
            Last Name
          </td>
          <td>
            <input type="text" name="LastName"  id="LastName"/>
          </td>
        </tr>
        <tr>
          <td align="right">
            Email
          </td>
          <td>
            <input type="text" name="Email" id="Email" />
          </td>
        </tr>
        <tr>
          <td align="right">
            Phone
          </td>
          <td>
            <input type="text" name="Phone" id="Phone" />
          </td>
        </tr> 
        <tr>
          <td align="right">
            Address
          </td>
          <td>
            <textarea name="Address" id="Address" cols="23" rows="5" ></textarea>
          </td>
        </tr>
 <tr> &nbsp;</tr>
           <tr>
          <td align="right"></td>
 <td>
            <div id="error"> </div>
</td>
        </tr>
        <tr>
          <td align="right"></td>
          <td>
            <input type="submit" value="Submit" />
          </td>
        </tr>
</table>
    </form>
</form>
</body>
</html>



Divisible By Five in JavaScript

A simple program that will ask the user to give a number our program will check if the given number by our user is divisible by five or not using JavaScript as our programming language.

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>
 Divisible By Five
 </title>
 </head>
 <style>
        h3 {
    font-family:arial;
    }
</style>  
 <body>
  <h3> Divisible By Five</h3>
<script>
  var value_number = Number(prompt("Enter a Number : "));
 
   if(value_number % 5 == 0)
        {
            document.write("<font face='arial' size='4'> ");
document.write("The number  " +value_number+
" is divisible by 5. </font>");
        }
        else
        {
            document.write("<font face='arial' size='4'> ");
document.write("The number " + value_number+ 
" is not divisible by 5. </font>");
        }
   </script> 
  </body>
 </html>

Compounded Interest Solver In JavaScript

A simple program that I wrote in JavaScript programming language that will compute the compounded interest rate from the money being borrowed by the person. The code is very simple and very easy to understand. I intended my work for beginners in JavaScript programming.

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>
 Compounded Interest Solver
 </title>
 </head>
 <style>
        h3 {
    font-family:arial;
    }
</style>  
 <body>
  <h3> Compounded Interest Solver</h3>
<script>

 var principal=0,years=0,rate=0;
   principal = 10000;
   years  = 10;
   rate = .05; 
   
 document.write("<font face='arial' size='4'> ");
 document.write("Principal Amount    :  Php " + principal + "</font><br>");
  document.write("<font face='arial' size='4'> ");
  document.write("Years    : " + years + "</font><br>");
  document.write("<font face='arial' size='4'> ");
  document.write("Interest Rate : " + rate + "</font><br>");
  document.write("<font face='arial' size='4'> ");
  document.write("<br>");
  document.write("Total Amount Compounded over the " + years +" years.</font>");
  document.write("<br><br>");
   for(x=1; x<=years; x++) {
amount = parseFloat(principal) * Math.pow(1+parseFloat(rate),x);
    document.write("<font face='arial' size='4'> ");
document.write("Year " + x  + " : Php "  + amount.toFixed(2) +"</font><br>");
}
  </script> 
  </body>
 </html>

Maximum of Two Numbers in JavaScript

In this article I will share with you a simple program that I wrote in JavaScript that will check and determine which of the two numbers given by our user is the highest or bigger it only uses if - else statement in comparing which of the two number is much bigger.  I intended my work for beginners in JavaScript programming.

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>
 Maximum Between Two Numbers
 </title>
 </head>
 <style>
        h3 {
    font-family:arial;
    }
</style>  
 <body>
  <h3> Maximum Between Two Numbers </h3>
<script>
  var first_number = Number(prompt("Enter First Number : "));
  var second_number = Number(prompt("Enter Second Number : "));

   if(first_number > second_number)
        {
            document.write("<font face='arial' size='4'> ");
document.write("The " +first_number+
" is much bigger than " + second_number + ".</font>");
        }
        else if (second_number > first_number)
        {
            document.write("<font face='arial' size='4'> ");
document.write("The number " + second_number+ 
" is much bigger than " + first_number + ".</font>");
        }
   </script> 
  </body>
 </html>