Friday, October 23, 2015

Floyd's Triangle in JavaScript

A simple program that I wrote the will generate the Floy'ds Triangle using 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

<head>
  <title>Floyd's Triangle </title>
</head>
<style>
h3 {
   font-family:arial;
   };
 </style>
<body>
  <script>
    
    var rows=0, number = 1, counter=0, j=0;
var num_value = parseInt(prompt("Enter number: "));

document.write("<br>");
document.write("<h3> Floyd's Triagle</h3>");
     for ( counter = 1 ; counter <= num_value; counter++ )
       {
           for ( j = 1 ; j <= counter ; j++ )
           {
                
                document.write("<font face='arial' size='3'>");
                document.write(" " + number + " </font>");
number++;
           }
           document.write("<br>");
       }
      document.write("<h3> End of Program </h3>");
</script>
</body>
</html>


Basic Math Operations in JavaScript

Here is a sample program that demonstrate how to use JavaScript to perform basic math operations. The code is very easy to understand 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>Basic Math in JavaScript </title>
</head>
<style>
h3 {
   font-family:arial;
   };
  </style>
<body>
  <script>
var num1 = parseInt(prompt("Enter first vallue : "));
var num2 = parseInt(prompt("Enter second vallue : "));

var sum = (num1 + num2);
var difference = (num1 - num2);
var product = (num1 * num2);
var quotient = (num1 / num2);
    
document.write("<br>");
document.write("<h3> Basic Math in JavaScript </h3>");
document.write("<font face='arial' size='3'> The sum of ");
document.write(+ num1 + " and " + num2 + " is " + sum + ".</font><br>");
document.write("<font face='arial' size='3'> The difference of ");
document.write(+ num1 + " and " + num2 + " is " + difference + ".</font><br>");
document.write("<font face='arial' size='3'> The product of ");
document.write(+ num1 + " and " + num2 + " is " + product + ".</font><br>");
document.write("<font face='arial' size='3'> The quotient of ");
document.write(+ num1 + " and " + num2 + " is " + quotient + ".</font><br>");
document.write("<h3> End of Program </h3>");
</script>
</body>
</html>

Area of a Rectangle in JavaScript

A program in JavaScript that will ask input value from the user and then compute the area of the rectangle.

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 Rectangle</title>
</head>
<style>
h3 {
   font-family:arial;
   };
</style>
<body>
  <script>
    
var length = parseInt(prompt("Enter length of Rectangle : "));
var width = parseInt(prompt("Enter width of Rectangle : "));
   
    var solving_area = (length * width);
 
document.write("<br>");
document.write("<h3> Area of Rectangle</h3>");
document.write("<font face='arial' size='3'>")
    document.write(" The Length of Rectangle is " + length + ".</font><br>");
document.write("<font face='arial' size='3'>")
    document.write(" The Width of Rectangle is " + width + ".</font><br><br>");
    document.write("<font face='arial' size='3'>")
    document.write(" The Area of Rectangle is " + solving_area + ".</font>");
document.write("<h3> End of Program </h3>");
</script>
</body>

</html>

Count the Capital and Small Letters in a Word in JavaScript

This program will ask the user to enter a word or a sentence and then our program will count the capital letters and small letters on it.

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>
 <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 onload="check_odd_even()">
<script language="javascript" type="text/javascript">
function  check_odd_even() 
   {
    var str = prompt("Enter a word");
var count=0,small=0;
var len=str.length;
  for(var i=0;i<len;i++) {
    if(/[A-Z]/.test(str.charAt(i))) 
{
count++;
    }
else {
 small++;
}
  }
  document.write("<h3>Orignal word : " + str + " <br> No.  of Capital Letters " +count + ". </h3>");
  document.write("<h3>Orignal word : " + str + "<br> No.  of Small Letters "   +small + ". </h3>");
  return count;
}
 </script>
</body >

</html>

Decimal To Binary Converter in JavaScript

This simple program that I wrote in JavaScript will ask the user to enter a decimal value and then it will convert it into binary format.

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>Decimal To Binary Converter </title>
 </head>
    <body>
<h2> Decimal To Binary Converter </h2>
    <script>
function decimal_to_binary(dec,length){
  var output_result = "";
  while(length--)
    output_result += (dec >> length ) & 1;    
  return output_result;  
}
   
var input = parseInt(prompt("Enter a Number"));
input_solve = decimal_to_binary(input,8);
if (!isNaN(input)) {
  document.write("<h2>" +input + "<sub>10</sub> in decimal is equivalent to " 
  + input_solve + "<sub>2</sub> in binary. </h2>" );
 }
while(isNaN(input)){
input = parseInt(prompt("Please enter a numerical value."));
input_solve =decimal_to_binary(input,8);
if (!isNaN(input)) {
  document.write("<h2>" +input + "<sub>10</sub> in decimal is equivalent to " 
  + input_solve + "<sub>2</sub> in binary.</h2>" );
 }
}
</script>
</body>

</html>

Binary To Decimal Converter in JavaScript

A simple program that I wrote in JavaScript that will ask the user to enter a binary value and then convert the given binary value into decimal format.

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>Binary To Decimal Converter </title>
 </head>
    <body>
<h2> Binary To Decimal Converter </h2>
    <script>
function binary_to_decimal( binaryNumber ) {
        
   
   var decimalNumber = 0;


   var placeValue = 1;

  
   while ( binaryNumber > 0 ) {

     
     var remainder = binaryNumber % 10;

      var digitValue = remainder * placeValue;

     decimalNumber = decimalNumber + digitValue;

       placeValue *= 2;

     
     binaryNumber = Math.floor( binaryNumber / 10 );
   }

   
   return decimalNumber;
 }
    var input = parseInt(prompt("Enter a Number"));
input_solve = binary_to_decimal(input);
if (!isNaN(input)) {
  document.write("<h2>" +input + "<sub>2</sub> in binary is equivalent to " 
  + input_solve + "<sub>10</sub> in decimal. </h2>" );
 }
while(isNaN(input)){
input = parseInt(prompt("Please enter a numerical value."));
input_solve =binary_to_decimal(input);
if (!isNaN(input)) {
  document.write("<h2>" +input + "<sub>2</sub> in binary is equivalent to " 
  + input_solve + "<sub>10</sub> in decimal.</h2>" );
 }
}
</script>
</body>
</html>

Sunday, October 18, 2015

Swing Payroll System in Java

A payroll program that I wrote in Java a long time ago that uses swing library for it graphical user interface design that will compute the salary of an employee in the company.

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

import javax.swing.*;
import java.awt.event.*;


public class payroll extends JFrame implements
ActionListener {

JTextField emp_name = new JTextField(15);
JTextField work     = new JTextField(15);
JTextField rate     = new JTextField(14);
JTextField days     = new JTextField(15);


JButton Compute = new JButton("Compute");
JButton Clear   = new JButton("Clear");


   JLabel emp_label2 = new JLabel();
    JLabel work_label2 = new JLabel();
    JLabel salary = new JLabel();
    JLabel report = new JLabel();

    double solve = 0.00;

public payroll() {

  super("Simple Payroll System");
  setSize(260,280);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  JPanel pane = new JPanel();

  JLabel emp_name_label = new JLabel(" Name         ");
  JLabel work_label     = new JLabel(" Position     ");
  JLabel rate_label     = new JLabel(" Rate Per Day ");
  JLabel days_label     = new JLabel(" No. of Days  ");

  pane.add(emp_name_label);
  pane.add(emp_name);

  pane.add(work_label);
  pane.add(work);


  pane.add(rate_label);
  pane.add(rate);
  pane.add(days_label);
  pane.add(days);

  pane.add(Compute);
  pane.add(Clear);

  Compute.addActionListener(this);
  Clear.addActionListener(this);
  Compute.setToolTipText("Click here to solve the salary.");
  Clear.setToolTipText("Click here to clear text fields.");

  pane.add(report);
  pane.add(emp_label2);
  pane.add(work_label2);
  pane.add(salary);
  add(pane);

  setVisible(true);
}

public void actionPerformed(ActionEvent e)
{

if(Compute==e.getSource())
{
                  String name= emp_name.getText();
                  String work2= work.getText();

             double emp_rate=Double.parseDouble(rate.getText());
             int emp_days = Integer.parseInt(days.getText());

             solve = (emp_rate * emp_days);

               report.setText(" === Salary Report === ");
                emp_label2.setText("Employee's Name  : "
                                    +name);
                work_label2.setText("Job Description : "
                                     +work2);
                salary.setText("   Employee's Salary : $ " +
                 String.format("%.2f",solve));

}

else if(Clear==e.getSource())
{
emp_name.setText("");
                work.setText("");
                rate.setText("");
                days.setText("");

                report.setText("");
                emp_label2.setText("");
                work_label2.setText("");
                salary.setText("");
}
}


public static void main(String[] args)
{
payroll employee = new payroll();
}
}

Database File Maintenance in Visual Basic 6

A database file maintenance that I work with a long time ago in my database programming using Visual Basic 6 and Microsoft Access. This program will demonstrate the basic database operations like add, edit, delete, view records as will as report generation.

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


Finding the Largest Number in Visual Basic 6

A program that I wrote before that uses looping statement and conditional statement in Visual Basic 6 to check a series of numbers and then determine which of the given number is the largest.

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



Hexadecimal To Octal Converter in Visual Basic 6

A program that I wrote a long time ago in my programming class in Visual Basic 6 that will ask the user to enter a value in Hexadecimal and then our program will convert that value into Octal equivalent.

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




Odd and Even Number Checker in Visual Basic 6

A simple program that I wrote before to check if the given number by the user is odd or even number using Visual Basic 6.

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


Binary to Decimal Converter in Visual Basic 6

A simple program that I wrote a long time ago in my programming class in Visual Basic 6. What does the program will do is to ask the user to enter binary value and then the program will convert the binary value to its decimal equivalent.

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



Keypress Navigation in Visual Basic 6

A simple code that I wrote a long time ago in Visual Basic 6 that enables the user to navigate between text boxes in the form in Visual Basic 6 the code is very simple for beginners in Visual Basic 6.

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.