Sunday, May 31, 2015

Payroll Database System in C++

In this article I will share with you a program that I wrote in C++ that will manage the payroll system of the employees in the company I called this program Payroll Database System in C++ that uses text file to save the records of the employees. In this program I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler that is very available over the Internet for free because it is an open source.

If you have some questions regarding about my work 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 at 09173084360.

Thank you and Happy Programming.



Sample Program Output

Program Listing

#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<sstream>
#include<iomanip>

using namespace std;

void append();
void find();
void read();
void whattodo();
void loop();
void about();
void mainfind();

int main()
{
    system("Color 2F");

    cout<<"\t\t\t------------------"<<endl;
    cout<<"\t\t\t* Payroll System *"<<endl;
    cout<<"\t\t\t------------------"<<endl;
    whattodo();
    getch();
    return 0;
}
void whattodo()
{

    int choice;

    loop:


   cout << "\n\t\t Created By: Mr. Jake R.Pomperada, MAED-IT";
    cout << "\n\n";

    cout<<"Type the number of the command you want to perform:"<<endl;
    cout<<endl;
    cout<<"[1] Append Record"<<endl;
    cout<<"[2] Browse all file contents"<<endl;
    cout<<"[3] Find a record"<<endl;
    cout<<"[4] Exit"<<endl;
    cout<<"[5] About"<<endl;
    cout<<""<<endl;

    cin>>choice;

    cout<<""<<endl;
     if (choice==1)
        {
            system("cls");
            append();
            cout<<endl;
            loop();
        }
       else if (choice==2)
        {
            system("cls");
            read();
            cout<<endl;
            loop();
        }
        else if(choice==3)
        {
            system("cls");
            mainfind();
            loop();
        }
        else if(choice==4)
        {
            system("cls");
            cout<<"Goodbye.";
        }
        else if(choice==5)
        {
            system("cls");
            about();
        }
        else
        {
            cout<<"Invalid! Try again."<<endl;
            goto loop;
        }

    system ("cls");
}

void append()
{
     string emp_first, emp_last;
     string id;
     double salary=0.00;
     ofstream fout;
     fout.open("myRecord.txt",ios::app);    // open file for appending



     cout<<"Enter Employee Id: ";
      cin >> id;

      cout << "\n";
     cout<<"Enter Employee Name: ";
     cin >> emp_first >> emp_last;

     cout<<"Enter Employee Salary:";
     cin >> salary;
     fout << setiosflags(ios::fixed | ios :: showpoint)
        << setprecision(2);
            fout<<  id<< ", " << emp_first
                << " " << emp_last << " , " << salary << endl;
            fout << fixed;

     fout.close( );       //close file


}


void read()
{
    string line;
    ifstream x ("myRecord.txt");

    if (x.is_open())
    {
    while(!x.eof())
    {

    cout<<endl;
    getline(x,line);
    cout<<line<<endl;

    }
    x.close();
    }
    else
    cout<<"Cant open file."<<endl;
}
void find()
{
    ifstream data("myRecord.txt");
    string item,line;
    int x=0;
    int y=0;
    string id;

    cout<<endl;
    cout<<"Enter Employee Id: ";
    cin>>id;
    cout<<""<<endl;

    while(!data.eof())
    {
        getline(data,line);
        string item_array[10];
        stringstream stream(line);
        x=0,y=0;

        while(getline(stream,item,','))
        {
            item_array[x]=item;
            x++;
            item_array[y]=item;
            y++;
        }

        if(item_array[0]==id)
        {
            cout<<setfill('-')<<left<<setw(10)<<"\t\t\tID:   " <<right<<"  "<<item_array[0]<<endl;
            cout<<setfill('-')<<left<<setw(10)<<"\t\t\tName: " <<right<<" "<<item_array[1]<<endl;
            cout<<setfill('-')<<left<<setw(10)<<"\t\t\tRate: " <<right<<" "<<item_array[2]<<endl;
            cout<<""<<endl;
        }
    }
    data.close();
}
void loop()
{
    string choice;
    cout<<""<<endl;
    cout<<"Do you want to make another choice?(yes/no)";
    cin>>choice;
    system("cls");
    cout<<""<<endl;
        if (choice=="yes")
        {
            whattodo();
        }
        else if(choice=="no")
        {
            cout<<"Goodbye.";
        }
}
void about()
{
    cout<<endl;
    cout<<"                    ABC Computer Training Center"<<endl;
    cout<<"                     1st Floor, Victoria Center"<<endl;
    cout<<"                Bacolod City, Philippines Tel.No. 4335081"<<endl;
    cout<<"                          Endterm Exams"<<endl;
    cout<<""<<endl;
    cout<<"                 Professor       : Sir Jake R. Pomperada"<<endl;
    cout<<""<<endl;
    cout<<"                 Project Manager : Juan Dela Cruz"<<endl;
    cout<<""<<endl;
    cout<<"                 Program Designer: Pedro Santa Maria"<<endl;
    cout<<""<<endl;
    loop();
}
void mainfind()
{
    find();

    string id;
    cout<<"Type back to go to main menu."<<endl;
    cout<<"Press any key to find another profile."<<endl;
    cin>>id;
    system("cls");

    if (id=="back")
    {
        whattodo();
    }
    else
    {
        mainfind();
        find();
    }
}




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>