Saturday, August 27, 2016

Payroll Program in COBOL

Here is a simple program payroll program that I wrote in COBOL that will ask the user to give the employees name, daily rate and number of days work and then our program will compute the employees salary.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.
  



Sample Program Output

Program Listing


******************************************************************
* Author: MR. JAKE R. POMPERADA
* Date: AUGUST 27, 2016        SATURDAY
* Purpose: PAYROLL PROGRAM
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. PAYROLL_PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 name_emp PIC X(20).
77 daily_rate PIC 9(4).
77 days_work PIC 9(4).
77 solve_salary PIC 9(4).
PROCEDURE DIVISION.
PARA.
DISPLAY "PAYROLL PROGRAM IN COBOL".
DISPLAY "".
DISPLAY "Name of the employee :".
ACCEPT name_emp.
DISPLAY "Give Daily Rate : ".
ACCEPT daily_rate.

DISPLAY "Number of Days Worked : ".
ACCEPT days_work.
COMPUTE solve_salary = (daily_rate * days_work).
DISPLAY "".
DISPLAY " Name : " name_emp.
DISPLAY "Gross Salary : Php " solve_salary.
STOP RUN.


 
 

Average of Three Numbers in COBOL

A simple program that I wrote using COBOL that will ask the user to give three numbers and then our program will find the average of the three numbers given by our user.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.
  


 Sample Program Output


Program Listing



******************************************************************

* Author: MR. JAKE R. POMPERADA
* Date: AUGUST 27, 2016 SATURDAY
* Purpose: AVERAGE OF THREE NUMBERS
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. AVERAGE_THREE_NUMBERS.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 NUM_1 PIC 9(4).
77 NUM_2 PIC 9(4).
77 NUM_3 PIC 9(4).
77 SOLVE_AVERAGE PIC 9(4).
PROCEDURE DIVISION.
PARA.
DISPLAY "AVERAGE OF THREE NUMBERS IN COBOL".
DISPLAY "".
DISPLAY "ENTER THE FIRST VALUE : ".
ACCEPT NUM_1.
DISPLAY "ENTER THE SECOND VALUE : ".
ACCEPT NUM_2.
DISPLAY "ENTER THE THIRD VALUE : ".
ACCEPT NUM_3.
COMPUTE SOLVE_AVERAGE = (NUM_1 + NUM_2 + NUM_3)/3.
DISPLAY "THE AVERAGE IS " SOLVE_AVERAGE.
STOP RUN.


Average of Three Numbers in Turbo Pascal

A simple program that will ask the user to give three numbers and then our program will compute the average of the three numbers being provided by the user.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.
  



Sample Program Output


Program Listing

Program average_three_numbers;
Uses WinCrt;

Var
  Choice : Char;
  num1,num2,num3 : Integer;
  Average : Real;

Begin
  Clrscr;
  Choice := 'Y';
  Write('Average of Three Numbers in Turbo Pascal');
  Writeln;
  Writeln;
  While upcase(Choice) = 'Y' Do
    Begin
     Writeln;
     Write('Enter three numbers : ');
     Readln(num1,num2,num3);
     Average := (num1+num2+num3)/3;
     Writeln;
     Write('The Average is ' ,Average:8:2,'.');
     Writeln;
     Writeln;
     Write('Continue [Y/N] : ');
     readln(choice);
     Writeln;
    End;
    Writeln;
    Write('End of Program');
    Writeln;
  Readln;
End.

Area of the Circle in Turbo Pascal

Here is a sample program that I wrote using Turbo Pascal for Windows to ask the user the radius of the circle and then our program will compute the area of the circle.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.
 



Sample Program Output


Program Listing
 
Program area_of_the_circle;
Uses WinCrt;
Const
  Pi = 3.1416;
Var
  Choice : Char;
  radius  : Integer;

Procedure convert_area(var radius : integer);
Var
  Area : real;
 
Begin
 Area := Pi * Radius * Radius;
 writeln('The Radius is ',Area:8:2);
End;

Begin
  Clrscr;
  Choice := 'Y';
  Write('Area of the Circle Converter');
  Writeln;
  Writeln;
  While upcase(Choice) = 'Y' Do
    Begin
     Writeln;
     Write('Enter the area of the circle : ');
     Readln(radius);
     Writeln;
     convert_area(radius);
     Write('Continue [Y/N] ');
     readln(choice);
     Writeln;
    End;
    Writeln;
    Write('End of Program');
    Writeln;
  Readln;
End.



Celsius To Fahrenheit in Turbo Pascal

A simple program that I wrote using Turbo Pascal that will ask the user to give the temperature in Celsius and then it will convert it in Fahrenheit equivalent.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.
 
 
 
Sample Program Output
 
 
Program Listing
 
Program celsius_to_fahrenheit;
Uses WinCrt;

Var
  Choice : Char;
  Celsius  : Integer;

Procedure convert_fahreneheit(var celsius : integer);
Var
  Fahrenheit : real;
 
Begin
 Fahrenheit:= (9/5) * celsius + 32;
 writeln('The Fahrenheit is ',Fahrenheit:8:4);
End;

Begin
  Clrscr;
  Choice := 'Y';
  Write('Celsius To Fahrenheit Converter');
  Writeln;
  Writeln;
  While upcase(Choice) = 'Y' Do
    Begin
     Writeln;
     Write('Enter temperature in Celsius : ');
     Readln(Celsius);
     Writeln;
     convert_fahreneheit(Celsius);
     Write('Continue [Y/N] ');
     readln(choice);
     Writeln;
    End;
    Writeln;
    Write('End of Program');
    Writeln;
  Readln;
End. 

Inches To Centimeter in Turbo Pascal

A simple program that I wrote using Turbo Pascal to ask the user to give a value in inches and then it will convert it to centimeter equivalent.  The code is very simple and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

Program Inch_To_Cm;
Uses WinCrt;

Var
  Choice : Char;
  inch   : Integer;

Procedure inchtocm(var inch : integer);
Var
  Cm : real;
Begin
 cm := inch * 2.54;
 writeln(inch, ' inch is equal to ',cm:5:2,' cm');
End;

Begin
  Clrscr;
  Choice := 'Y';
  Write('Inch To Centimeter Converter');
  Writeln;
  Writeln;
  While upcase(Choice) = 'Y' Do
    Begin
     Writeln;
     Write('Give the value in inch : ');
     Readln(inch);
     Writeln;
     inchtocm(inch);
     Write('Continue [Y/N] ');
     readln(choice);
     Writeln;
    End;
    Writeln;
    Write('End of Program');
    Writeln;
  Readln;
End.



Saturday, August 20, 2016

Reverse a Number in Turbo Pascal

Here is a sample program that I wrote using Turbo Pascal For Windows that will ask the user to give a number and then our program will reverse the arrangement of the number.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

Program Reverse_Number;
Uses WinCRT;

Var N,R : Longint;

Begin
  Clrscr;
  Write('Reverse a Number');
  writeln;
  Writeln;
  Write('Give a Number : ');
  Readln(N);
  Writeln;
  Write('===== The Result ======');
  Writeln;
  Writeln;
  Write('The Original Order : ',N);
  Writeln;
  Write('The Reverse Order  : ');
  While (N<>0) Do
    Begin
      R:= N MOD 10;
      Write(R);
      N := N Div 10;
    End;
    Readln;
  End.
 
 

Word Count in C++

Here is a sample program that I wrote in C++ that will count the number of words in a given sentence.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.




Program Listing


#include<iostream>
#include<string>


using namespace std;

char str1[150],tmp;
int i=0,j=0,w=0,l=0;


void CntWords(char str1[150])

{

l=strlen(str1);

for (i=1;i<=l;i++)

 {


  if (str1[i]==' '&&str1[i+1]!=' ')
  {
  w++;


  }else{
  if (str1[i]!=' '&&str1[l]!=' '&&l==i)
  {
  w++;

  }


  }


 }

  if (str1[1]==' ' && str1[2]==' ')
   {

   w--;
   }

 tmp=str1[l-1];

 if (tmp==' ')
 {
 w--;

 }
}


 main()
{


cout << "\t\t  Word Count Version 1.0 ";
cout << "\n\n";
cout << "Type Words :=>  ";
gets(str1);

CntWords(str1);

cout << "\nThe Counted Words " << w;
cout << "\n\n";
system("PAUSE");


}





 

Count Vowels and Consonants in PERL CGI

A simple program that I wrote using PERL CGI to count the number of vowels and consonants in a given word or a sentence. The code is very simple and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing

vowels_consonants.cgi

#!"D:\xampp\perl\bin\perl.exe"
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
print "Content-type: text/html\n\n";


print "<html>
<style>
body {
     font-family:arial;
     font-size:15;
     color:blue;
    }

</style>
<head><title>Count Vowels and Consonants in PERL CGI</title></head>
<body bgcolor='lightgreen'>
    <h3>Count Vowels and Consonants in PERL CGI</h3>
    <b>Written By: Mr. Jake R. Pomperada,MAED-IT</b>
    <br><br>
    <form action='' method='post'>
        <label>Enter a word or a sentence :<label>
        <input type='text' name='string' size=50/>
        <br><br>
        <input type='submit' value='Ok' />
    </form>
</body>
</html>";  

my $q = new CGI;

if($q->param())
{
    $string = lc($q->param('string'));
    @vowels = ("a","e","i","o","u");
    @consonants=("b","c","d","f","g","h","j","k","l"
                ,"m","n","p","q","r","s","t","v","w","x","y","z");
    $len = length($string);
    $num1 = 0;

  
    @strarr = split(//, $string);
   

    for($i=0; $i<$len; $i++){

        if(in_array(\@vowels, $strarr[$i]))
        {
            $num1++;
        }
      
        if(in_array(\@consonants, $strarr[$i]))
        {
            $num2++;
        }
    }
    print "<br><br>";
    print "<b>===== DISPLAY RESULTS =====</b>";
    print "<br><br>";
    print "The given string or sentence :  <span style='color:red; font-weight:bold;'>".$string."</span></p>";
    print "<p>Number of Vowels : <span style='color:red; font-weight:bold;'>". $num1 ."</span></p>";
    print "<p>Number of Consonants : <span style='color:red; font-weight:bold;'>". $num2 ."</span></p>";

    sub in_array {
         my ($arr,$search_for) = @_;
         return grep {$search_for eq $_} @$arr;
    }
}

Friday, August 19, 2016

Factorial in Turbo Pascal

A simple program that I wrote using Turbo Pascal for Windows to accept an integer value from the user and then our program will compute the factorial value of the given number by the user.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.






 Sample Program Output



Program Listing

Program Factorial_Program;

Uses WinCrt;


Var

   Fact : Longint;
   n    : Integer;

Function Factorial(n : integer) : longint;
Begin
 If N < 1 then
   Begin
   factorial := 1;
   End
 Else
   Factorial := n * factorial(n-1);
End;

Begin
 Clrscr;
 Write('Factorial Program in Turbo Pascal');
 writeln;
 Writeln;
 Write('Enter a Number : ');
 Readln(n);
 fact := factorial(n);
 writeln;
 Writeln('The factorial of ',n:1,' = ',fact,'.');
 Readln;
End.


Fibonacci Numbers in Turbo Pascal

Here is a sample program that I wrote using Turbo Pascal For Windows to compute the fibonacci number based on the given number by the user.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.



 
Sample Program Output

Program Listing

Program Fibonacci;
Uses WinCrt;

Var N  : Integer;

Function fib(n:integer) : integer;
Begin
 If (n=0) OR (n=1) then
   Begin
   fib := 1;
   End
 Else
  fib:= fib(n-1)+fib(n-2);
End;

Begin
   Clrscr;
   Writeln('FIBONACCI NUMBERS IN PASCAL');
   Writeln;
   Write('Give a Number : ');
   Readln(n);
   Writeln;
   Writeln('The Fibonacci(n) = ',fib(n),'.');
   Readln;
End.



Product of Two Numbers in PERL CGI

A simple program that I wrote that will ask the user to give two numbers and then our program will find the product of the two numbers using PERL CGI.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.




Sample Program Output

Program Listing

 product.cgi


#!"D:\xampp\perl\bin\perl.exe"
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $q = new CGI;

my $num1 = $q->param(val1);
my $num2 = $q->param(val2);
print "Content-type: text/html\n\n";

print "<html>
<style>
body {
     font-family:arial;
     font-size:15;
     color:blue;
    }

</style>
<head><title>Product of Two Numbers in Perl CGI</title></head>
<body bgcolor='lightgreen'>
    <h3>Product of Two Numbers in PERL CGI</h3>
    <b>Written By: Mr. Jake R. Pomperada,MAED-IT</b>
    <br><br>
    <form action='' method='post'>
        <label>Enter First Number <label>
        <input type='text' name='val1' value='' autofocus/><br><br>
        <label>Enter Second Number  </label>
        <input type='text' name='val2' value='' />
        <br><br>
        <input type='submit' value='Submit' />
   
    <input type='reset' name='Reset' value='Reset'/></form>
</body>
</html>";   


if($q->param())
{
   
 
    $product = $num1 * $num2;
   
        print "<p>The product of $num1 and $num2 is $product.</p>";
   
}

 

 

Palindrome in Perl

In this article I would like to share with you a sample program the I wrote in PERL CGI to accept a string and then it will check if the given string is a palindrome or not a palindrome. The code is very easy to understand and use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

#!"D:\xampp\perl\bin\perl.exe"

use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

print "Content-type: text/html\n\n";
print "<html>
<style>
body {
     font-family:arial;
     font-size:15;
     color:blue;
    }

</style>
<head><title>Palindrome Program in PERL CGI</title></head>
<body bgcolor='lightgreen'><br>
    <h3>Palindrome Program in PERL CGI</h3>
    <b>Written By: Mr. Jake R. Pomperada,MAED-IT</b>
    <br><br><br>
    <form action='' method='post'>
        <label>Give a String : <label>
        <input type='text' name='string' />
        <br><br>
        <input type='submit' value='Ok'
        title='Click to know if the string a palindrome or not a palindrome.'/>
    </form>
</body>
</html>";   


my $q = new CGI;

if($q->param())
{
    $string = lc($q->param('string'));
   
    $string=~s/ //g;
   
    $string =~ s/[^A-Za-z0-9]//g;
   
    $reverse = reverse($string);

    $display = uc($string);
   
    if($string eq $reverse){
      
        print "<br>";
        print "<p>The String <b>$display</b> is Palindrome.</p>";
    }else{
        print "<br>";
        print "<p>The String  <b>$display</b> is not Palindrome.</p>";
    }
   
}



Friday, August 12, 2016

Checking Age in Cobol

Here is a simple program that I wrote entirely in COBOL that shows how to use if statement. This program will ask the user's and then our program will check and determine whether the user is an adult or a minor. The code is very simple and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.



My mobile number here in the Philippines is 09173084360.




Sample Program Output
 
 
Program Listing
 
******************************************************************
* Author: MR. JAKE R. POMPERADA,MAED-IT
* Date: AUGUST 12, 2016
* Purpose: AGE CHECKER PROGRAM IN COBOL
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. AGE_CHECKER.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 AGE PIC 9(4).
PROCEDURE DIVISION.
PARA.
DISPLAY "CHECKING AGE IN COBOL".
DISPLAY "".
DISPLAY "WHAT IS YOUR AGE?".
ACCEPT AGE.
IF AGE >=18 THEN
DISPLAY "YOU ARE ALREADY AN ADULT.".
IF AGE < 18 THEN
DISPLAY "SORRY YOU ARE STILL A MINOR.".
STOP RUN.