Sunday, November 5, 2017

Swap of Two Numbers in C#

Here is a simple program that I wrote using C# as my programming language to demonstrate how to use methods in C#. I will swap the arrangement of two numbers.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.




Sample Program Output


Program Listing

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    public class Swap_Number
    {

        public static void Swap(ref int x, ref int y)
        {
            int swap;

            swap = x;
            x = y;
            y = swap;
        }

        public static void Main()
        {
            int x = 10;
            int y = 15;

            Console.WriteLine("Swap Two Numbers in C# ");
            Console.Write("\n");
            Console.WriteLine("By Mr. Jake R. Pomperada, MAED-IT ");
            Console.Write("\n\n");
            Console.WriteLine("Before  ");
            Console.Write("\n\n");
            Console.WriteLine("x: {0} , y: {1}", x, y);
            Swap(ref x, ref y);
            Console.Write("\n\n");
            Console.WriteLine("After  ");
            Console.Write("\n\n");
            Console.WriteLine("x: {0} , y: {1}", x, y);
            Console.Write("\n\n");
            Console.Write("\t Thank You For Using This Software.");
            Console.ReadKey();
        }
    }
}


Friday, November 3, 2017

Addition of Two Numbers in C++

A simple program of adding the sum of two numbers that I wrote using C++.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.


Program Listing

#include <iostream>
#include <string>
#include <stdlib.h>


using namespace std;


main() {

    int sum=0,a=0,b=0;
    char reply;

do {
    system("cls");
    cout << "\t\t Addition of Two Numbers";
    cout << "\n\n";
    cout << "Enter the first value  : ";
    cin >> a;
    cout << "\n";
    cout << "Enter the second value : ";
    cin >> b;
    cout << "\n\n";
       sum =(a+b);
    cout << "The sum of " << a <<" and "
    <<b << " is " << sum <<".";
    cout << "\n\n";
    cout << "Do you want to continue y/n : ";
    cin >> reply;
    if (toupper(reply) == 'N') {
        cout << "\n\n";
        cout << "\t\t Thank You For Using This Software !!!";
        break;
    }
    } while (toupper(reply!='Y'));
    cout << "\n\n";
    system("pause");

}




XYZ Chat System Using PHP and MySQL


Communication is one of the most aspect of our human life as we are born in this world. We have learned how to communicate by gestures, hand signal and the language that is being taught to us by our parents.  There are thousands of languages and dialects all over the world that makes communication with other people more difficult and needs most of the time a translator just to translate one language to another language. One of the official language the is being spoke by millions of people around the world is the English language. The language itself is very universal the most text books and novels are being written using the English language.

Because of our shrinking world now a day’s communication becomes more easier compared to the past. I still remember during my early age my parents teach us how to write a letter and drop the letter to the post office. That’s the time the Internet is not widely used nor not yet existing in our country here in the Philippines.  By mid 1990’s the introduction of the Internet in our society paved way to a new method of communication the use of email, chat, text, voice over IP and video conferencing becomes a common medium of communication among us. It makes our communication to our friends, family members and relatives more efficient and best of all cost less. The interaction is in real time so there’s no need for us to wait for weeks or months just to receive the reply letter or message.

In this article I will teach you and discuss how to make a chat system using PHP and MySQL. When I have learned how to use mIRC, Yahoo Messenger and more recently chat system in Facebook I have also some questions in my mind how to create my own chat system. As I said before the use of Internet as source of information is very common now a days and very beneficial after some research I find some codes and try to improve and add functionality the is suited in my needs. That’s I came out with the program called XYZ Chat System 1.0 Using PHP and MySQL.  In writing the code I started with the use of HTML,CSS for the framework and layout of my page. After that I use JQuery  to refresh my page is every 1 second and finally the use of PHP and MySQL to save the messages in our database.

What the program will do is very simple I will ask the user to enter the name of the person below is a text field where all the conversation will be display to the end user and finally a text file where the user type the message and by clicking the send message it will display the message of the screen and save the message including the name of the sender in our MySQL database so we can monitor and retrieve whatever conversation that our user has in our system. This program is very simple there are still many things that can be done just to improve its overall functionality in general.

I test the chat system in my localhost it means in one computer and a LAN network. If you like to test this program in a LAN network my advice is for your mapped first the server computer and assign its IP address and for the of the client computer you also assigned a different IP address for example let say the server IP address is 192.168.20.10 when we access our program via the web browser we can use a command like this http://192.168.20.10/chat/index.php as simple with this command we can access of chat system that is being mapped in our windows operating system.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.









Sample Program Output


Here is the complete program listing of XYZ Chat System 1.0 Using PHP and MySQL

index.php

<?php
session_start();
if(isset($_POST['submit']))
{
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("chat", $con);
                                $message=$_POST['message'];
                                $sender=$_POST['sender'];
                                mysql_query("INSERT INTO message(message, sender)VALUES('$message', '$sender')");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XYZ Chat System 1.0</title>
<script language="javascript" src="jquery-1.2.6.min.js"></script>
<script language="javascript" src="jquery.timers-1.0.0.js"></script>
<script type="text/javascript">

$(document).ready(function(){
   var j = jQuery.noConflict();
                j(document).ready(function()
                {
                                j(".refresh").everyTime(1000,function(i){
                                                j.ajax({
                                                  url: "refresh.php",
                                                  cache: false,
                                                  success: function(html){
                                                                j(".refresh").html(html);
                                                  }
                                                })
                                })
                               
                });
               
   j('.refresh').css({color:"red"});
});
</script>
<style type="text/css">
.refresh {
    border: 1px solid black;
                border-left: 4px solid black;
    color: green;
    font-family: tahoma;
    font-size: 12px;
    height: 225px;
    overflow: auto;
    width: 400px;
                padding:10px;
                background-color:#FFFFFF;
}
#post_button{
                border: 1px solid #3366FF;
                background-color:#3366FF;
                width: 100px;
                color:#FFFFFF;
                font-weight: bold;
                margin-left: -105px; padding-top: 4px; padding-bottom: 4px;
                cursor:pointer;
}
#textb{
                border: 1px solid black;
                border-left: 4px solid black;
                width: 320px;
                margin-top: 10px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; width: 415px;
}
#texta{
                border: 2px solid black;
                border-left: 4px solid black;
                width: 410px;
                margin-bottom: 10px;
                padding:5px;
}
p{
border-top: 1px solid #EEEEEE;
margin-top: 0px; margin-bottom: 5px; padding-top: 5px;
}
span{
                font-size:12;
                font-weight: bold;
                color: green;
}
</style>
</head>
<body bgcolor="lightgreen">
<font face="comic sans ms">
<h1> <center> XYZ Chat System 1.0 </center> </h1> </font>
<br>
<form method="POST" name="" action="">
<input name="sender" type="text" id="texta"  value="<?php echo $sender ?>"/>
<div class="refresh">
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("chat", $con);
$result = mysql_query("SELECT * FROM message ORDER BY id DESC");
while($row = mysql_fetch_array($result))
  {
  echo '<p>'.'<span>'.$row['sender'].'</span>'. '&nbsp;&nbsp;' . $row['message'].'</p>';
  }

mysql_close($con);
?>
</div>
<input name="message" type="text" id="textb"/>
<input name="submit" type="submit" value="Send Message" id="post_button" />
</form>
</body>
</html>

Here is the code that will refresh all the conversations of the user in chat system
refresh.php
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chat", $con);
$result = mysql_query("SELECT * FROM message ORDER BY id DESC");
while($row = mysql_fetch_array($result))
  {
  echo '<p>'.'<span>'.$row['sender'].'</span>'. '&nbsp;&nbsp;' . $row['message'].'</p>';
  }
mysql_close($con);
?>

chat.sql

-- phpMyAdmin SQL Dump
-- version 3.1.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 01, 2014 at 03:55 AM
-- Server version: 5.1.30
-- PHP Version: 5.2.8

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `chat`
--

-- --------------------------------------------------------

--
-- Table structure for table `message`
--

CREATE TABLE IF NOT EXISTS `message` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `message` text NOT NULL,
  `sender` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;

--
-- Dumping data for table `message`
--

INSERT INTO `message` (`id`, `message`, `sender`) VALUES
(2, 'Welcome to our school Maria?', 'Mario'),
(3, 'Thank you Mario for the warm accommodation.', 'Maria'),
(4, 'What are your subject this semester?', 'Mario'),
(5, 'My subjects are Science, Math, English and Accounting.', 'Maria'),
(6, 'See you in school Maria God Bless you always.', 'Mario'),
(7, 'Thanks and Take care always.', 'Maria'),
(8, 'good bye maria', 'Mario'),
(9, 'Thank you Mario I hope we can me friends', 'Maria'),
(11, 'Good bye', 'Maria');



Total Days To Year, Weeks and Days Converter in C++

In this article I would like to share with you a sample program that will ask the user to give the total number of days and then our program will count the number of years, weeks and days on the given total days using C++ as our programming language.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.






Sample Program Output


Program Listing

#include <iostream>

using namespace std;

int main()
{
    int no_days=0, years=0, weeks=0,days=0;

    cout << "\t Total Days To Year, Weeks and Days Converter in C++";
    cout << "\n\n";
    cout << "Created By Mr. Jake R. Pomperada, MAED-IT";
    cout << "\n\n";
    cout << "How many total days : ";
    cin >> no_days;

    years = (no_days/365);
    weeks = (no_days % 365) / 7;
    days  = (no_days % 365) % 7;

    cout << "\n\n";
    cout << no_days << " Days " << years << " year(s) "
         << weeks << " weeks "<< days  << " days " << ".";
    cout << "\n\n";
    cout << "End of Program.";
    cout << "\n\n";

}


Thursday, November 2, 2017

Employee's Information System in C++

Here is a very simple employee's information system that I wrote using C++ in a very long time ago when I am still teaching in the University here in my hometown in Bacolod City. I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler in writing this simple program using struct as my data structure.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.


Program Listing


#include <iostream>
#include <iomanip>

using namespace std;


  struct emp  {
      string name;
      int age;
      float salary;
  };

  main() {
      emp users[3];
        cout << "\t Employees Information System";
      cout << "\n\n";
      for (int x=0; x<3; x+=1) {
       cin.ignore();
       cout << "Enter your name  :";
       getline(cin,users[x].name);

       cout << "Enter your age    :";
       cin >> users[x].age;
       cout << "Enter your salary :";
       cin >> users[x].salary;
      }
  cout << "\n\n";
      cout << "\t List of Employees";
      cout << "\n\n";
      for (int x=0; x<3; x+=1) {
      cout << setprecision(2) << fixed;
      cout   << "\n" << setw(5) << users[x].name
          << setw(10) << users[x].age
          << setw(15) << users[x].salary;
      }
      cout << "\n\n";
      system("pause");
  }


Product of Two Numbers Using Function in C++

A very simple program that I wrote that will ask the user to give two numbers and then our program will compute the product using function in C++. The code is very simple and easy to understand it also shows you how to use one dimensional array in C++.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.



Program Listing


 #include <iostream>
 #include <iomanip>

  using namespace std;

 // Global variable

  int val[2],product=0;

   void accept() {
       cout << "Enter two numbers : ";
       cin >> val[0] >> val[1];
   }

   int solve(int a, int b)
    {
     return(a*b);
    }

    void display()
    {

       cout << setw(50) <<"The product is "
            << solve(val[0],val[1])
            << ".";
    cout << "\n\n";
    system("pause");
    }

main() {
    accept();
    display();
}

Number Occurrence in C++

In this article I would like to share with you a sample program that I wrote in C++ a long time ago to count the number of occurrence of the given number by the user.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.


Program Listing


#include <iostream>

using namespace std;


main(void) {
 int items[5];
    int search=0;
    int occur=0,x=0;


    for (int x=0; x<5; x++) {
        cout << "Enter Item No."
            << x+1 << " : ";
        cin >> x[items];
    }

     cout << "\n\n";
     cout <<"Enter Item to search :";
     cin >> search;
    for (x=0; x<5; x++) {
     if (search == x[items]) {
         occur++;

     }

    }
 cout << "\n\n";
     cout << "Number occurence of is "
         << occur << ".";




     if (search != x[items]) {
         cout << "Not Found in the List.";

     }


     cout << "\n\n";
     system("pause");
}

Person Record System in Codeigniter

In this article I would like to share with you the work of my good friend and fellow software engineer Jai Soni from India a simple Person Record System in Codeigniter which allows the user to add, edit and delete persons information in the database. I am very thankful that Jai share his work us.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.







Sample Program Output







Saturday, October 28, 2017

Number of Days Before Christmas Counter in JavaScript

Here is a sample program that I wrote that will count the number of days before Christmas using JavaScript.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.



Sample Program Output


Program Listing

<html>
<title>  Number of Days Before Christmas in JavaScript </title>
<body>
<style>
body {
 font-family:arial;
 font-size:50px;
 font-weight:bold;
 color:blue;
 background-color:lightgreen;
}
</style>
<br>
<h4> Number of Days Before Christmas in JavaScript </h4>
<script>
var day_description = "Christmas";
var day_before = "Christmas Eve";

var today = new Date();
var year = today.getYear();
if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000))
year="19" + year;
if (navigator.appName == "Netscape")
year=1900 + year;
var date = new Date("December 25, " + year);
var diff = date.getTime() - today.getTime();
var days = Math.floor(diff / (1000 * 60 * 60 * 24));

if (days > 1)
document.write("There are " + (days+1) + " days until " + day_description + "!");
else if (days == 1)
document.write("Tommorrow is " + day_before  + "!");
else if (days == 0)
document.write("Today is " + day_before + "!");
else if (days == -1)
document.write("It's " + day_description + "!");
else if (days < -1)
document.write(day_description + " was " + ((days+1)*-1) + (days < -2 ? " days" : " day") + " ago this year!");

</script>
</body></html>