Sunday, December 20, 2015

Switch Statement in JavaScript

In this article I would like to share with you guys how to use and declare switch statement in JavaScript as our programming language. Switch statement is another type of conditional statement mainly use to check for conditions based on the values that is being provided by our user of our program. The advantage of using switch statement is that it is easy to understand in terms  of declaration and usage but the problem with switch statement we are not allow to use logical and relational operators that why many of conditional statements are using if - else statement instead of switch statement.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.  

My mobile number here in the Philippines is 09173084360.


Program Listing

<html>
<head>
<title> Switch Statement in JavaScript</title>
</head>
<body>
<script language = "Javascript">
var v = parseInt (prompt ("Enter a number from 0 - 9 ONLY!!!", " "));
switch (value) {
case 0:
document.write("<b>Number " + v + " is " + "ZERO in word format.");
break;
case 1:
document.write("<b>Number " + v + " is " + "ONE in word format.");
break;
case 2:
document.write("<b>Number " + v + " is " + "TWO in word format.");
break;
case 3:
document.write("<b>Number " + v + " is " + "THREE in word format.");
break;
case 4:
document.write("<b>Number " + v + " is " + "FOUR in word format.");
break;
case 5:
document.write("<b>Number " + v + " is " + "FIVE in word format.");
break;
case 6:
document.write("<b>Number " + v + " is " + "SIX in word format.");
break;
case 7:
document.write("<b>Number " + v + " is " + "SEVEN in word format.");
break;
case 8:
document.write("<b>Number " + v + " is " + "EIGHT in word format.");
break;
case 9:
document.write("<b>Number " + v + " is " + "NINE in word format.");
break;
default:
document.write("<b>Invalid Number!");
}
</script>
</body>
</html>

Search a record in PHP and MySQL

A simple program that I wrote before in PHP and MySQL to search a record from the database. The code is very easy to understand and use in your projects related to PHP and MySQL.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.  

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Personnel Mailing List System in CakePHP

There are many PHP frameworks in the market today one of the most simple and easiest PHP framework in CakePHP I find easy to learn and understand in this article I would like to share with you an application that I wrote using CakePHP. I called this application Personnel Mailing List System that will store the name, home address, telephone, mobile and email address of a person in a company.

This application is based on the work of my friend and fellow software engineer Mike Dalisay in this website https://www.codeofaninja.com. I am thankful that Mike share his knowledge and skills in CakePHP I learned a lot from it.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.  

My mobile number here in the Philippines is 09173084360.

Reference:

https://www.codeofaninja.com/2012/04/cakephp-2x-crud-tutorial.html






Sample Program Output










Friday, December 18, 2015

Average of Five Numbers in Python

This is a simple program that I wrote using Python as my programming language that will find the average of five numbers that is being given by the user. I am still learning how to program in Python I find it very easy to write simple program ideal for beginners in Python programming in general sense.

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

print('\n')
print('\t Average of Five Numbers')
print('\n')
val1 = int(input('Enter first  value : '))
val2 = int(input('Enter second value : '))
val3 = int(input('Enter third  value : '))
val4 = int(input('Enter fourth value : '))
val5 = int(input('Enter fifth  value : '))

average = (val1+val2+val3+val4+val5) /5

print('\n')
print("The average of five numbers is {0}.".format(round(average,2)))
print('\n')
print('Thank you for using this program')





Odd and Even Number in Python

A simple program that I wrote in Python programming language to check if the number given by the user is odd or even 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.



Sample Program Output


Program Listing

print('\n')
print('\t Odd and Even Number Checker')
print('\n')
number_value = int(input('Enter a Number : '))

if (number_value % 2) == 0:
   print(" The given number {0} is an EVEN number.".format(number_value))
else:
   print("The given number {0} is an ODD number.".format(number_value))

print('\n')
print('Thank you for using this program')





Area of a Circle Solver in Python Version 2

A second version of my program in Python to solve the area of a circle based on the given radius 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

import math

print('\n')
print('\t Area of the Circle Solver')
print('\n')
radius = input('Enter the radius of the circle: ')

area= (radius**2) * math.pi
print('\n')
print('The radius of the circle is {0}.'.format(radius))
print('The area of the circle is {0}. '.format(round(area,2)))
print('\n')
print('Thank you for using this program')



Addition of Three Numbers in Python

This sample program that I wrote using Python programming language  will find the sum of three numbers given by the user. I find Python programming easy to understand and learn I am still a beginner in Python programming so to speak. I hope you will find my work useful in learning Python 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


print('Addition of Three Numbers')
print('\n')
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
num3 = input('Enter third number: ')

sum = float(num1) + float(num2) + float(num3)

print('\n')
print('The sum of {0},{1} and {2} is {3}'.format(num1, num2,num3,sum))
print('\n')
print('Thank you for using this program')


Tuesday, December 15, 2015

addition of two numbers in java

This sample program that I wrote in Java will compute the total of two numbers using applet as our graphical user interface. I used this code as one of my programming laboratory activities during the time I working as college professor. I hope you will find my work useful in your quest to learn Java 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

    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.Label;

    public class add extends Applet implements ActionListener{
      TextField text1,text2,output;
      Label label1,label2,label3,title;
      Button button,clear;
      public void init(){
        setLayout(null);


          title = new Label("Addition of Two Numbers");
          title.setBounds(80,10,140,20);
          add(title);
          title.setAlignment(title.CENTER);

        label1 = new Label("Enter Number 1: ");
        label1.setBounds(20,50,100,20);
        add(label1);

        text1 = new TextField(5);
        text1.setBounds(150,50,100,20);
        add(text1);

        label2 = new Label("Enter Number 2: ");
        label2.setBounds(20,90,100,20);
        add(label2);

        text2 = new TextField(5);
        text2.setBounds(150,90,100,20);
        add(text2);

        label3 = new Label("Sum of Two Numbers: ");
        label3.setBounds(20,130,130,20);
        add(label3);

        output = new TextField(5);
        output.setBounds(150,130,100,20);
        add(output);

        button = new Button("Sum");
        button.setBounds(150,170,100,20);
        add(button);

        clear = new Button("Clear");
        clear.setBounds(280,170,100,20);
        add(clear);

        button.addActionListener(this);
        clear.addActionListener(this);


        }
        public void actionPerformed(ActionEvent ae){
        int num1=Integer.parseInt(text1.getText());
        int num2=Integer.parseInt(text2.getText());
        int sum=num1+num2;
        output.setText(Integer.toString(sum));
            if(ae.getSource() == clear)
            {
                 text1.setText("");
              text2.setText("");
               output.setText("");
               text1.requestFocus();
    }
}
}

 

Grade Solver Using Java

This program that I wrote before compute the grade of the student using Java as our programming language. The code is not very difficult and I am using applet to generate the graphical user interface. I hope you will find my program useful.

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 java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.Label;
    import java.text.DecimalFormat;

     public class grade extends Applet implements ActionListener{
      TextField txtprelim,txtmidterm,txtprefinal,txtendterm, txtfinal,txtremarks;
      Label lblprelim,lblmidterm,lblprefinal,lblendterm,lblfinal,lblremarks,title;
      Button button,clear;

 DecimalFormat dFormat = new DecimalFormat("0");
      public void init(){
        setLayout(null);


          title = new Label("Grade Solver 1.0");
          title.setBounds(90,20,150,20);
          add(title);
          title.setAlignment(title.CENTER);

        lblprelim = new Label("Prelim Grade ");
        lblprelim.setBounds(20,50,100,20);
        add(lblprelim);

        txtprelim = new TextField(5);
        txtprelim.setBounds(150,50,100,20);
        add(txtprelim);

        lblmidterm = new Label("Midterm Grade");
        lblmidterm.setBounds(20,90,100,20);
        add(lblmidterm);

        txtmidterm = new TextField(5);
        txtmidterm.setBounds(150,90,100,20);
        add(txtmidterm);

        lblprefinal = new Label("Prefinal Grade");
        lblprefinal.setBounds(20,130,130,20);
        add(lblprefinal);
        txtprefinal = new TextField(5);
        txtprefinal.setBounds(150,130,100,20);
        add(txtprefinal);


        lblendterm = new Label("Endterm Grade");
        lblendterm.setBounds(20,170,130,20);
        add(lblendterm);
        txtendterm = new TextField(5);
        txtendterm.setBounds(150,170,100,20);
        add(txtendterm);


        lblfinal = new Label("Final Grade");
        lblfinal.setBounds(20,210,100,20);
        add(lblfinal);
        txtfinal = new TextField(5);
        txtfinal.setBounds(150,210,100,20);
        add(txtfinal);


        lblremarks = new Label("Remarks");
        lblremarks.setBounds(20,250,100,20);
        add(lblremarks);
        txtremarks = new TextField(5);
        txtremarks.setBounds(150,250,100,20);
        add(txtremarks);

        button = new Button(" Solve Grade ");
        button.setBounds(70,280,100,20);
        add(button);

        clear = new Button(" Clear ");
        clear.setBounds(230,280,100,20);
        add(clear);

        button.addActionListener(this);
        clear.addActionListener(this);
        }

        public void actionPerformed(ActionEvent ae)
        {

      double prelim =Double.parseDouble(txtprelim.getText());
      double midterm =Double.parseDouble(txtmidterm.getText());
        double prefinal =Double.parseDouble(txtprelim.getText());
      double endterm =Double.parseDouble(txtmidterm.getText());
     
       double pre = (prelim * 0.2);      double pref = (prefinal * 0.2);
      double mid = (midterm * 0.2);   double endt = (endterm * 0.4);

      double compute_final_grade = (pre+mid+pref+endt);

       txtfinal.setBackground(Color.black);
       txtfinal.setForeground(Color.white);
       txtfinal.setText(dFormat.format(compute_final_grade));
       txtfinal.setEditable(false);

        if (compute_final_grade >= 75) {
            txtremarks.setBackground(Color.yellow);
            txtremarks.setForeground(Color.blue);
            txtremarks.setText("Passed");
        }
         else{
          txtremarks.setBackground(Color.yellow);
           txtremarks.setForeground(Color.red);
            txtremarks.setText("Failed");
        }
         txtremarks.setEditable(false);

            if(ae.getSource() == clear)
            {
             txtprelim.setText("");
              txtmidterm.setText("");
              txtprefinal.setText("");
               txtendterm.setText("");
               txtfinal.setText("");
               txtremarks.setText("");
               txtprelim.requestFocus();
    }
}
}


Ways to display a value of a variable in PHP

This very short program that I wrote using PHP as my programming language will give you an idea how to display a value of a variable in different ways in PHP that I have learned during the course of my learning in PHP programming. I intended this one for beginners in PHP 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
 
<?php
$name1 = "John Smith";
$name2 = "Anna Morgan";
$name3 = "Nadine Samonte";

echo "Hello ",$name1," How are you? <br>";

echo "Hello ".$name2."<br>";


echo "Hello $name3";




Sunday, December 13, 2015

Sending Email in PHP

A program that I wrote before in PHP using PHP Mailer to send email using PHP as our primary language. The code is not very difficult but you must know how to use PHP Mailer and knows how to configure your gmail email account in order to use this program correctly.

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


Subject Information System in PHP and MySQL

This application I wrote a long time ago in PHP and MySQL that uses join sql queries to connect several tables to extract the needed information from several tables I called this program Subject Information System in PHP and MySQL. Feel free to use my code in your programming assignments and projects.

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



Passed and Failed Grade Lister in C language

I simple program that I wrote two years ago that will ask the user to give a series of grades pass and failing grades and then our program will counter how many grades given by the user is failed and passed. The code also teaches how to write and use one dimensional array in C 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.
  


Program Listing

#include <stdio.h>
#include <stdlib.h>

main() {
    int list=0,pass=0,fail=0, grades[5];

     printf("\n\t\tPASS AND FAIL LISTER 1.0");
     printf("\n\n");
    for (list=0; list < 5; list++) {
        printf( "Enter Grade No  %d :", list+1 );
        scanf("%d",&list[grades]);
    }

        for (list=0; list < 5; list++) {

      if (list[grades] >= 75) {

         pass++;

     }

     else {
         fail++;
       }
    }


// display pass grades and failed grades
  printf("\n");
  printf("\n==============================");
  printf("\n====== Generated Report ======");
  printf("\n==============================");
  printf("\n\n");
  printf( "Passed Grades => ");

        for (list=0; list < 5; list++)


        {

      if (list[grades] >= 75) {

      printf(" %4d ",list[grades] );
     }

    }
 printf("\n");

printf("Failed Grades => ");

        for (list=0; list < 5; list++)
        {

      if (list[grades] < 75) {

        printf(" %4d ",list[grades] );
     }

    }

    printf("\n");
    printf("\nNumber of Passed Grades => %d. ",pass);
    printf("\nNumber of Failed Grades => %d. " ,fail);
    printf("\n\n");
    system("PAUSE");
    }
  // End of Code