Tuesday, May 15, 2018

Addition And Product of Two Numbers in Visual Basic NET

Here is a program that will ask the user to give two numbers and then our program will compute the sum and product of the two number being provided by our user using Visual Basic NET.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.





Sample Program Output



Program Listing

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As Integer
        Dim b As Integer
        Dim sum As Integer
        Dim product As Integer

        a = CInt(Me.TextBox1.Text)
        b = CInt(Me.TextBox2.Text)

        sum = (a + b)

        product = (a * b)


        Label4.Text = "The sum of " & a & " and " & b & " is  " & sum & "."
        Label5.Text = "The product of " & a & " and " & b & " is  " & product & "."
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Label4.Text = ""
        Label5.Text = ""
        Me.TextBox1.Text = ""
        Me.TextBox2.Text = ""
        Me.TextBox1.Focus()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim n As String = MsgBox("Do you really want to exit?", MsgBoxStyle.YesNo, "Quit Program?")
        If n = vbYes Then
            Me.Close()
        Else
            Me.Show()
            Label4.Text = ""
            Label5.Text = ""
            Me.TextBox1.Text = ""
            Me.TextBox2.Text = ""
            Me.TextBox1.Focus()
        End If
    End Sub
End Class

Connect To MySQL Database in PHP

Here is a simple code to connect MySQL to PHP.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.



Program Listing

connect.php

<?php
define(MYSQL_HOST, 'localhost');
define(MYSQL_USER, 'root');
define(MYSQL_PASS, '');
define(MYSQL_DB, 'USERSDB');

$db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
if (!$db)
{
die('<br />Failed to connect to host "' . MYSQL_HOST . '".');
}
else
{
mysql_select_db(MYSQL_DB);
}
?>

Using SETW in C++

In this article I would like to share with you a simple program to show how to use setw or set width in C++.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.



Program Listing

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

using namespace std;

int main() 
{
    cout<<"Apple"<<endl;
    cout<<"Banana"<<endl;
    cout<<"123.456"<<endl;

    cout<<endl;

    cout<<setw(10);
    cout<<"Apple"<<endl;
cout<<setw(10);
cout<<"Orange"<<endl;
 
    
    cout<<setw(10)<<"Banana"<<endl;
    cout<<setw(10)<<"123.456"<<endl;

    cout<<endl;
    
    //no setw, so no formatting
    cout<<"Apple"<<endl;
    cout<<"Orange"<<endl;
      

    system("pause");
    return 0;
}

Hangman in C++

Here is a simple game hangman written in C++. It uses a text file to store word to be guess it runs in Dev C++ or CodeBlocks.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.



Program Listing

hangman.cpp

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


inline void type_of_word(char f);


int main()
{   char c,h,ch,ch1,ch2;
    char word[25];
    char word2[25];

    int l,i,ng,n,k,x;

do{  do{
        c='\0';
        cout<<"\n\t\t     H A N G M A N  IN  C++ \n\n\n";
        cout<<"(E) Enter a word\n\n(C) Computer chooses word\n\n(A) Add new word to list\n\n(Q) Quit\n\n\nEnter your choice (E - C - Q): ";
        cin>>ch2;
       }while (ch2!='C' && ch2!='c' && ch2!='E' && ch2!= 'e' && ch2!='Q' && ch2!= 'q'&& ch2!='A' && ch2!= 'a');
    if (ch2 == 'Q' || ch2=='q')  exit (0);

    if (ch2 == 'C' || ch2=='c')

    {
        ifstream fin("hangword.txt");
        if(!fin) { 
        cout<<"File missing, aborting.\n\nYou are missing a file of name **hangword.txt**\n\nLocate it, then place it next to the program file.\n\n"; system("pause"); return 0;}
        for (i=0;!fin.eof();i++)   fin.getline(word,25);
        fin.close();

        do {
        x=rand();
        }while(x>i || x<0);

        ifstream finn("hangword.txt");
        for (i=0;!finn.eof();i++)
        {finn>>c; finn.getline(word,25); if (x==i) break;}
        finn.close();
    }

  if (ch2 == 'A' || ch2=='a')

    {
        ofstream fout("hangword.txt",ios::app);
        if(!fout) {
        cout<<"File missing, aborting.\n\nYou are missing a file of name **hangword.txt**\n\nLocate it, then place it next to the program file.\n\n"; system("pause"); return 0;}
        cin.get();
        cout<<"Choose the topic of your word\n\n(M) Movie\n\n(A) Animal\n\n(P) Sport\n\n(S) Song\n\nEnter your choice (A-P-S-M) : ";
        cin>>h;
        cin.get();
        cout<<"\n\nThe word should not exceed 25 letters\n\nEnter the word : ";
        cin.getline(word,25);
        fout<<h<<word<<endl;
        fout.close();

    }


   if (ch2 == 'E' || ch2=='e')
     {
       cin.get();
       cout<<"\t\t\t Type the word :  ";
       cin.getline (word, 25);
     }
 if (ch2 == 'E' || ch2=='e' || ch2 == 'C' || ch2=='c')
{
l=strlen(word);
char choosen[25]="\0";
n=0;k=0;



 for(i=0;i<=24;i++)
   {
    if (word[i]=='\0') {word2[i]='\0';break;}
    if (word[i]==' ')  {word2[i]=' ';  n++;}
    if (word[i]!=' ')  word2[i]='-';
   }
ng=l+2-n;     
   do{
   there:  type_of_word(c);
     if (k!=0)  cout<<"\n\n\t\t\tChoosen letters : "<<choosen<<"\n";
     cout<<"\n\n\n\t\t\t      "<<word2<<"\n\n\nYou have "<<ng<< " guesses left, choose a letter : ";
     cin>>ch; cin.get();
     for (i=0;i<25;i++) if (choosen[i]==ch) {
     cout<<"\a\t\t     !!You have choosen "<<ch<<" already!!\n";goto there;}
     ng--; choosen [k]=ch; choosen [k+1]=',';k+=2;



     for (i=0;i<=24;i++)    if (word[i]==ch || word[i]==ch+32 || word[i]==ch-32) word2[i]=ch;
     if (!strcmpi (word2,word)) {cout<<"\n\t\t\t      "<<strupr(word)<<"\n\n\t\t\tCongratulations  :-()\n"; break;}

    }while(ng>0 || !strcmpi (word2,word));


if (strcmpi (word2,word))  cout<<"\nSorry, maybe next time.\n\nThe word was : "<<strupr(word)<<endl;
}

cout<<"\nWould you like to play again??? (Y - N) : ";
cin>>ch1;  cin.get();

}while (ch1=='y' || ch1=='Y');
      system("PAUSE");
      return 0;
}


inline void type_of_word(char f)

{    if (f=='m') cout<<"\t\t\t\tMOVIE";
     if (f=='a') cout<<"\t\t\t\tANIMAL";
     if (f=='p') cout<<"\t\t\t\tSPORT";
     if (f=='s') cout<<"\t\t\t\tSONG";

}


 hangman.txt

basketball
spelling
dog
cat
computer
car
food
assignment
pen
house
programming
science
money
business
work
password
recipe
electricity
water
gun
tree



Sunday, May 6, 2018

Palindrome Number in Turbo Pascal

In this article I would like to share with you a program that will prompts the user to give a number and then the program will check if the given number is a palindrome or not a palindrome using Pascal as our programming language.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.





Sample Program Output


Program Listing

palindrome.pas

program PalindromeNumber;

uses
  WinCrt;

var

n,m,x,r,s:longint;


Begin
  

write('Palindrome Number in Turbo Pascal');
writeln;
writeln;
write('Give a Number :  ');

read(n);

m:=n;

r:=0;

while n>0 do

begin

x:=n mod 10;

r:=r*10+x;

n:=n div 10;

end;


writeln;
writeln;

if m=r then
begin

writeln('The given number ' ,m, ' is  a Palindrome Number.')
end

else

writeln('The given number ' ,m, ' not a Palindrome Number.');

end.



Book Information Using Records in Turbo Pascal

Here is a program that I wrote using records in Pascal to accept and display the input information regarding the book. The code is very easy to understand I am using Turbo Pascal for Windows in this sample program.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.





Sample Program Output


Program Listing

books.pas

program BooksInformation;

uses
  WinCrt;  

  Type
Str200    = String[200];
TBookRec =
Record
Title, Author, ISBN : Str200;
                                Year  : Integer;
Price : Real;
End;

Procedure EnterNewBook(var newBook : TBookRec);
Begin

        Writeln('Book Information Using Records in Turbo Pascal.');
        Writeln;
Writeln('Please enter the book details: ');
Write('Book Name: ');
Readln(newBook.Title);
Write('Author: ');
Readln(newBook.Author);
Write('ISBN: ');
Readln(newBook.ISBN);
        Write('Year:');
        Readln(newBook.Year);
Write('Price: ');
Readln(newBook.Price);
End;

Procedure DisplayBookDetails(myBookRec : TBookRec);
Begin
Writeln('Here are the book details:');
Writeln;
Writeln('Title   :   ', myBookRec.Title);
Writeln('Author  :   ', myBookRec.Author);
Writeln('ISBN    :   ', myBookRec.ISBN);
        Writeln('Year    :   ', myBookRec.Year);
Writeln('Price   : $  ', myBookRec.Price:5:2);
        Writeln;
        Write('End of Program');
        Writeln;
End;

Var
bookRec : TBookRec;

Begin
EnterNewBook(bookRec);
Writeln('Thanks for entering the book details');
DisplayBookDetails(bookRec);
End.





Thursday, May 3, 2018

DESIGN PATTERN IN C

A very simple design pattern program that I wrote using C language.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.




Sample Program Output


Program Listing

design.c

/* May 2, 2018    */
/* Barangay Alijis, Bacolod City Negros Occidental Philippines */
/* Dev C++ */
/* Author : Mr. Jake R. Pomperada, MAED-IT */


#include <stdio.h>
#include <conio.h>


int main() 
{
     int i=0,j=0,k=0;
     char str[100];
     
     printf("======  DESIGN PATTERN IN C =====");
     printf("\n\n");
     printf("Created By Mr. Jake R. Pomperada, MAED-IT");
     printf("\n\n");
     printf("Give a String : ");
     scanf("%s",str);
     
     printf("\n\n");
     
     k=strlen(str);
     
     for (i=0; i<k; i++)
     {
         for (j=0; j<=i; j++)
          {
           printf(" %c ",str[j]);
          }
         printf("\n");
     }
    
    printf("\n\n\n\n");
    printf("===== END OF PROGRAM =====");
    printf("\n\n");
    system("pause");          
}




POINTER TO FUNCTION IN C

Here is a simple code to show how to use pointers to function in C.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.



Sample Program Output

Program Listing

pointers.c

/* May 2, 2018    */
/* Barangay Alijis, Bacolod City Negros Occidental Philippines */
/* Dev C++ */
/* Author : Mr. Jake R. Pomperada, MAED-IT */


#include <stdio.h>
#include <conio.h>

void Add(int,int);
void Product(int,int);


int main() 
{
     int a=0,b=0;
     
     printf("======  POINTER TO FUNCTION IN C =====");
     printf("\n\n");
     printf("Created By Mr. Jake R. Pomperada, MAED-IT");
     printf("\n\n");
     printf("Give Two Numbers : ");
     scanf("%d%d",&a,&b);
           
     void (*pf)(int,int);
     
     pf = Add;
     
     (*pf)(a,b);
     
     pf = Product;
     
     (*pf)(a,b);
     
     
    printf("\n\n\n\n");
    printf("===== END OF PROGRAM =====");
    printf("\n\n");
    system("pause");
}
  

 void Add(int x,int y)
 {
      int c=0;
      c = x + y;
      printf("\n\n");
      printf("The sum is %d.",c);
}
         
 void Product(int x,int y)
 {
      int d=0;
      d = x * y;
      printf("\n\n");
      printf("The product is %d.",d);
}



Lucas Series in C

A very simple program that I wrote to compute the Lucas series using C language.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. 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 Philippines is  +63 (034) 4335675.



Sample Program Output


Program Listing

lucas.c



#include <stdio.h>
#include <conio.h>

int main() 
{
     int a=0,b=0,c=0,d=0,i=0,n=0;
     
     printf("======  LUCAS SERIES IN C =====");
     printf("\n\n");
     printf("Created By Mr. Jake R. Pomperada, MAED-IT");
     printf("\n\n");
     printf("Give Number of Terms : ");
     scanf("%d",&n);
     
     printf("\n\n");
     
     a=1;
     b=1;
     c=1;
     
     printf(" %d %d %d",a,b,c);
     
     for (i=1; i<=(n-3); i++) {
         d = a + b + c;
         printf(" %d", d);
         a=b;
         b=c;
         c=d;
    }
    printf("\n\n\n\n");
    printf("===== END OF PROGRAM =====");
    printf("\n\n");
    system("pause");
}