Sunday, May 31, 2015

Payroll System Using Text File in C++

One of the most interesting aspect of computer programming is how to store or save the information that we process in a text file or database for future reference. In this article I would like to share with you a program that I wrote a long time ago in my class to teach my students in C++ programming how to store the processed information in a text file in C++. The code is very straight forward and easy to understand.  I hope many people will able to use this code as their basis in their learning how to program in C++.

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

People here in the Philippines who wish to contact me can reach me thru my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

#include <iostream>
#include <fstream>

 using namespace std;

 struct employee {
     string name,job;
     int age, rate, days;
     int solve_salary;
 };


 main() {
     employee user;
     ofstream myfile("result.txt");
     cout << "\t\t XYZ Payroll System";
     cout << "\n\n";
     cout << "Enter Name : ";
     getline(cin,user.name);
     cout << "Enter Job : ";
     getline(cin,user.job);
     cout << "Enter Age : ";
     cin >> user.age;
     cout << "Enter Rate Per Day : ";
     cin >> user.rate;
     cout << "Enter No. of Days Work : ";
     cin >> user.days;

      user.solve_salary = (user.days * user.rate);

       myfile << "\n=========================";
       myfile << "\t\n  XYZ PAYROLL SYSTEM ";
       myfile << "\n=========================";
       myfile << "\n Name    : " << user.name;
       myfile << "\n Job     : " << user.job;
       myfile << "\n Age     : " << user.age;
       myfile << "\n Salary  : $" << user.solve_salary;
       myfile.close();
       cout << "\n\n";
       system("pause");
 }




Passed and Failed Grades Counter in C++

In this article I would like to share with you a program that I wrote a long time that will ask the user to enter ten grades and then our program will count how many passed and failed grades given by our user of our program. The code is very simple enough it uses one dimensional array as its basic data structure and if - else statement for conditions.

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

People here in the Philippines who wish to contact me can reach me thru my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

// Pass and Failed Grades Counter
// Author : Mr. Jake Rodriguez Pomperada, MAED - Instructional Technology
// Date : November 13, 2009 Friday 10:22 PM
// Email : jakerpomperada@yahoo.com
// Tool  : Code Blocks
// Language : C++

#include <iostream>

using namespace std;

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

     cout << "\n\t\tPASS AND FAILED GRADES COUNTER";
     cout << "\n\t Created By: Mr. Jake R. Pomperada,MAED-IT";
     cout << "\n\n";
    for (list=0; list < 10; list++) {
        cout << "Enter Grade No " << list+1 <<  " :" ;
        cin >> list[grades];
    }

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

      if (list[grades] >= 75) {

         pass++;

     }

     else {
         fail++;
       }
    }

// display pass grades and failed grades
  cout << "\n";
  cout << "\n==============================";
  cout << "\n====== Generated Report ======";
  cout << "\n==============================";
  cout << "\n";
  cout << "Passed Grades => ";

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

        {

      if (list[grades] >= 75) {

      cout << " " <<  list[grades] << " ";
     }

    }
 cout << "\n";

cout << "Failed Grades => ";5

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

      if (list[grades] < 75) {

      cout << " " <<  list[grades] << " ";
     }

    }

    cout << "\n";
    cout << "\nNumber of Passed Grades => " << pass << ".";
    cout << "\nNumber of Failed Grades => " << fail << ".";
    cout << "\n\n";
    system("pause");
}
  // End of Code

Parallel Array in C++

In this article I would like to share with you a program that I wrote a long time ago in C++ to demonstrate the concepts of parallel array. According to Wikipedia.org, a group of parallel arrays is a data structure for representing arrays of records. It keeps a separate, homogeneous array for each field of the record, each having the same number of elements. Then, objects located at the same index in each array are implicitly the fields of a single record. Pointers from one object to another are replaced by array indices. This contrasts with the normal approach of storing all fields of each record together in memory.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.  People here in the Philippines who wish to contact me can reach me thru my mobile number 09173084360.

Thank you and Happy Programming.



Sample Program Output

Program Listing

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
 char str[][20] = {"Wally"," Skeeter"," Corky"," Jessie", "Sadie"}; 


    int val1[] = {18, 22, 12, 17, 15}; 
    int val2[] = {20 ,25 ,16 ,18 ,17 };

    cout << "\n\n";    
    cout << "\t Parallel Array in C++";
    cout << "\n\nCreated By: Mr. Jake R. Pomperada, MAED-IT";
    cout << "\n\n";    
    cout << setw(10) << "Name " << setw(12) << "Score 1" 
        << setw(10) << "Score 2";
    cout << "\n\n";    
    for(int index = 0; index < 5; index++)
{
     cout<<setw(10)<<str[index]
            <<setw(10)<<val1[index]
            <<setw(10)<<val2[index]<<endl;
}
    cout << "\n\n";    
    system("PAUSE");
    return EXIT_SUCCESS;

}


Saturday, May 30, 2015

Odd and Even Number Checker in BASH

In this article I would like to share with you a program that I wrote using BASH scripting language in Linux operating system I called this program Odd and Even Number Checker in BASH. This program is very simple and easy to understand the programs logic.

If you like my works please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippine can reach me at my mobile number at 09173084360.

Thank you very much and Happy Computing.




Sample Program Output

Program Listing

#!/bin/bash

echo -e "\n\n"
echo -e "\t\t Odd Or Even Number Checker in BASH"
echo -e "\n"
read -p  "Kindly Enter a Number :=> " value
echo -e "\n"

check=$(($value % 2))

if [ $check -eq 0 ]
   then
     echo "The number $value is an EVEN number."
   else
     echo "The number $value is an ODD number."
   fi
echo -e "\n"
echo -e "Thank you for using this program."





Addition of Two Numbers in Bash

In this article I would like to share with you one of my passion in programming writing Bash Script in Linux to automate or to make simple programs under Linux operating system. This program is very simple it will ask the user to enter two numbers and then it will display the sum of the two numbers to the user.

I am using Cgywin a linux distribution operating system that enables you run linux commands under windows it is totally free to download over the Internet here is the link https://www.cygwin.com/.

I hope you will find my simple script useful in your learning bash scripting programming in Linux operating system. If you have some questions feel free to send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines can reach me at this number 09173084360.

Thank you and Happy Programming.




Sample Program Output


Program Listing

#!/bin/bash

echo -e "\n\n"
echo -e "\t\t Addition of Two Numbers"
echo -e "\n"
read -p  "Enter two numbers : " a b

sum=$((a+b))
echo -e "\n"
echo "The sum of $a and $b is $sum."
echo -e "\n"
echo -e "Thank you for using this program."







Odd and Even Number Checker in JQuery

A program that I wrote using JQuery to check if the number given by the user is odd or even number I also included data validation.  I hope anyone will be benefit in this simple program.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can reach me at this number 09173084360.







Sample Program Output

Program Listing 

<html>
<title> Odd or Even Number Checker in JQuery</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 

    <script>
    $(document).ready(function(){

    function check_even_numbers(val)
    {
     return (val%2 == 0);
     }

    $("#number").focus();
    
    $("#check").click(function(){
        
        var item_no1 = $("#number").val();
      
    
        if (item_no1==0) {
            alert("Text field cannot be empty.");
            $("#number").focus();
        }
  
        else  if (/^[a-zA-Z0-9- ]*$/.test(item_no1) == false) {

          alert('Sorry it Contains Illegal Characters.');
          $("#number").focus();    
    }    
  
        else if (isNaN(item_no1))
        {
           alert("It is not a number but a letter(s) or alphabets.");
            $("#number").focus();    
            }
        
    else if (check_even_numbers(item_no1)) {              
                
      $('.display').html(item_no1 + " is an Even Number.");
    }
   else {
        $('.display').html(item_no1 + " is an Odd Number.");        
    }
});

// function to clear all the content of the text field

   $("#clear").click(function(){
          
           $(".display").html("");    
           $("#number").val(""); 
           $("#number").focus();
                  
    });

});

</script>

<style>

body {  
        background:lightgreen;
        color: blue ;
        font-family:arial;
        font-weight:bold;
        size:12;
     }
</style>


</head>
<body>
    <hr size="3" color="red">
<h2> Odd and Even Number Checker in JQuery </h2>
    <hr size="3" color="red">
<br><br>
Kindly enter a number :
<input type="text" id="number"  name="number" maxlength="5" size="5">
<br><br>
<button id="check" type="button" title="Click here to find if the number is odd or even ."> Check Number </button>
&nbsp;&nbsp;&nbsp;
<button id="clear" type="button" title="Click clear text box"> Clear </button>
<br><br><br>
<div class="display"></div>
</body>
</html>


Addition of Five Numbers Using JQuery with Data Validation

A simple program that I wrote using JQuery that will ask the user to enter five number with data validation that I include in this program. I hope you will find this simple program useful in learning how to program in JQuery.

If you have some questions please send me at email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines can reach me in this number 09173084360.

Thank you very much and Happy Computing.





Sample Program Output

Program Listing

<html>
<title> Additon of Five Numbers in JQuery</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 
<script>
$(document).ready(function(){
    
    // auto text field focus upon loading of our
    // webpage
    
    $("#item1").focus();
    
    // function to add all the five values in our text field
    
    $("#sum").click(function(){
        
        var sum = 0;               
    
        var item_no1 = $("#item1").val();
        var item_no2 = $("#item2").val();
        var item_no3 = $("#item3").val();
        var item_no4 = $("#item4").val();
        var item_no5 = $("#item5").val();
    
    // text field validation conditions checks if the text field
   //  does not have a value to sum up
        if (item_no1==0) {
            alert("Item No. 1 Cannot be empty.");
            $("#item1").focus();
        }
  
        else  if (/^[a-zA-Z0-9- ]*$/.test(item_no1) == false) {

          alert('Value in Item No. 1 Contains illegal Characters.');
          $("#item1").focus();    
    }    
  
        else if (isNaN(item_no1))
        {
           alert("Value in Item No. 1 is not a number but a letter.");
          $("#item1").focus();    
            }
        
    else if (item_no2==0) {
            alert("Item No. 2 Cannot be empty.");
            $("#item2").focus();
           }
  else  if (/^[a-zA-Z0-9- ]*$/.test(item_no1) == false) {
          alert('Value in Item No. 2 Contains illegal Characters.');
          $("#item2").focus();    
    }    
      
    else if (isNaN(item_no2))
         {
             alert("Value in Item No. 2 is not a number but a letter.");
            $("#item2").focus();    
            }    
    else if (item_no3==0) {
            alert("Item No. 3 Cannot be empty.");
            $("#item3").focus();
           }
    
     else  if (/^[a-zA-Z0-9- ]*$/.test(item_no3) == false) {

          alert('Value in Item No. 3 Contains illegal Characters.');
          $("#item3").focus();    
    }    
          
    else if (isNaN(item_no3))
         {
             alert("Value in Item No. 3 is not a number but a letter.");
            $("#item3").focus();    
            }        
    else if (item_no4==0) {
            alert("Item No. 4 Cannot be empty.");
            $("#item4").focus();
           }
   else  if (/^[a-zA-Z0-9- ]*$/.test(item_no4) == false) {

          alert('Value in Item No. 4 Contains illegal Characters.');
          $("#item4").focus();    
    }        
    else if (isNaN(item_no4))
         {
             alert("Value in Item No. 4 is not a number but a letter.");
            $("#item4").focus();    
            }        
    else if (item_no5==0) {
            alert("Item No. 5 Cannot be empty.");
            $("#item5").focus();
           }
    else  if (/^[a-zA-Z0-9- ]*$/.test(item_no5) == false) {

          alert('Value in Item No. 5 Contains illegal Characters.');
          $("#item5").focus();    
    }            
    else if (isNaN(item_no5))
         {
          alert("Value in Item No. 5 is not a number but a letter.");
            $("#item5").focus();    
            }        
    else {              
        $(".total_sum").each(function() {             
            sum+= Number($(this).val());         
        });
        
      $('.display').html("The total sum is " + sum + ".");
    }

});

// function to clear all the content of the text field

   $("#clear").click(function(){
          
         $(".total_sum").each(function() {             
            ($(this).val(""));         
           $(".display").html("");    
           $("#item1").focus();
         });
            
            
    });

});

</script>

<style>

body {  
        background:lightgreen;
        color: blue ;
        font-family:arial;
        font-weight:bold;
        size:12;
     }
</style>


</head>
<body>
    <hr size="3" color="red">
<h2> Addition of Five Numbers in JQuery </h2>
    <hr size="3" color="red">
<br><br>
Enter Item No. 1 :
<input type="text" id="item1" class="total_sum" name="item1" maxlength="5" size="5">
<br>
Enter Item No. 2 :
<input type="text" id="item2" class="total_sum" name="item2" maxlength="5" size="5">
<br>
Enter Item No. 3 :
<input type="text" id="item3" class="total_sum" name="item3" maxlength="5" size="5">
<br>
Enter Item No. 4 :
<input type="text" id="item4" class="total_sum" name="item4" maxlength="5" size="5">
<br>
Enter Item No. 5 :
<input type="text" id="item5" class="total_sum" name="item5" maxlength="5" size="5">
<br><br>
<button id="sum" type="button" title="Click here to find the sum of the five numbers."> COMPUTE </button>
&nbsp;&nbsp;&nbsp;
<button id="clear" type="button" title="Click clear text box"> CLEAR </button>
<br><br><br>
<div class="display"></div>
</body>
</html>


Wednesday, May 27, 2015

Greeter Program in JQuery

In this article I would like to share with you a sample program that I wrote using JQuery I called this program Greeter Program what does the program will do is to ask the user to enter the first name and last name of the user and then our program will greet the user. It teaches the user how to interact with HTML and JQuery using forms and buttons.

If you have some questions feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who would like to contact me can reach me at my mobile  number 09173084360.

Thank you very much and God Bless.





Sample Output of the Program



Program Listing

<html>

<head>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

</script>

<script>

 var txt=  $("#fname").val();

$(document).ready(function(){


$("#greet").click(function(){
   

    var f_name = $("#fname").val();
    var l_name = $("#lname").val();

    if(f_name==0) {
      alert("First Name cannot be empty");
      $(this).focus();
     }

  else if(l_name==0) {
      alert("Last Name cannot be empty");
      $(this).focus();
     }
   

  else {
    $('.display').html("Hello  " + f_name + " " + l_name + " How are you? ");

    
  }
   
   });


$("#clear").click(function(){
   
    var f_name = $("#fname").val(" ");
    var l_name = $("#lname").val(" ");
    $('.display').html(" ");    
    f_name.focus();
    });


});

</script>

<style>

body {  
        background:lightgreen;
        color: red;
        font-family:arial;
        font-weight:bold;
        size:12;
     }
</style>


</head>
<body>

Enter your First Name :
<input type="text" id="fname" name="fname" maxlength="20">
<br><br>
Enter your Last Name :
<input type="text" id="lname" name="fname" maxlength="20">
<br><br>
<button id="greet" type="button" title="Click here to display me"> Greet Me </button>
&nbsp;&nbsp;&nbsp;

<button id="clear" type="button" title="Click clear text box"> Clear Me </button>
<br><br><br>
<div class="display"></div>

</body>

</html>