Friday, September 29, 2017

Remove Digits in Java

In this article I would like to share with you a very simple program to ask the user to give a string which contains a numbers or digits and then our program will remove the digits or numbers in the given string by our user using Java 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.






Sample Program Output


Program Listing


Remove_Digits.java

/**
 * 
 */


package remove_digits;

import java.util.Scanner;


/**
 * @author Jake R. Pomperada
 * Bacolod City, Negros Occidental, Philippines
 * September 29, 2017  Friday    7:22 PM
*/


public class Remove_Digits {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
String str_one, str_two;
System.out.print("\n\n");
System.out.print("===== Remove Digits in Java ====");
System.out.print("\n\n");
System.out.print("===== Written By: Mr. Jake R. Pomperada =====");;
System.out.print("\n\n");

System.out.print("Enter a String : ");
str_one = input.nextLine();
System.out.print("\n\n");   
        
    str_two = str_one.replaceAll("[1234567890]", "");
   
    System.out.print("Original String :=> " + str_one + ".");
    System.out.print("\n\n");
    System.out.print("New String :=> " + str_two + ".");
    System.out.print("\n\n");
    System.out.println("END OF PROGRAM");
    System.out.println();
    input.close();
}

}






Friday, September 22, 2017

Addition of Three Numbers in Java Server Pages

In this article I would like to share with you a simple program that will ask the user to give three numbers and then it will find the total sum of the three numbers using Java Server Pages or JSP. The code is very simple and easy to understand. I hope you will find my work useful thank you very much for visiting my blog.

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.



Sample Program Output


Program Listing

index.htm

<html>

    <head>
        <title>Addition of Three Numbers in Java Server Pages</title>
    </head>
    
    <body>
        <br>  
        <h2> Addition of Three Numbers in Java Server Pages </h2>
         <b><i> Created By Mr. Jake R. Pomperada   <b> </i>
        <br><br>
        <form action="./add.jsp">
            First number  : <input type="text" name="t1"/> <br>
            Second number : <input type="text" name="t2"/> <br>
            Third number  : <input type="text" name="t3"/>
            <br><br>
            <input type="submit" value="Sum" alt="Click her to compute the sum of three numbers." />
        </form>
    </body>

</html>


add.jsp

<html>
    <head>
        <title>Enter two numbers to add up</title>
    </head>
    
    <body>

    <%!
      String val1;
      String val2;
      String val3;
      int val1_int;
      int val2_int;
      int val3_int;
      int sum;
      %>

        

     <% 

     val1 = request.getParameter("t1");    
     val1_int = Integer.parseInt(val1);   
  
     val2 = request.getParameter("t2");    
     val2_int = Integer.parseInt(val2);   

     val3 = request.getParameter("t3");    
     val3_int = Integer.parseInt(val3);

     sum = (val1_int + val2_int + val3_int);   

     %>

     <br>
     <h3> The total sum is <%= sum %>.  </h3>
    </body>
</html>








Wednesday, September 20, 2017

Selection Sort in Turbo Pascal

A program that I wrote using Pascal as my programming language that will ask the user how many items to be sorted and then our program will display the original arrangement of the numbers and finally it will display the sorted arrangement of numbers on our screen. I am using selection sort algorithm to sort the given numbers by our user. I am using Turbo Pascal for Windows as my programming environment. I hope you will find my work useful. Thank you.

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.





Sample Program Output


Program Listing

selection.pas

Program Selection_Sort;
uses Wincrt;

const
items = 100;

type
 values = array[1..items] of integer;

var
num,a,b  : integer;
list_items     : values;
min            : integer;
temp           : integer;


Begin
writeln;
writeln('Selection Sort Program in Turbo Pascal');
writeln;
writeln;
writeln('Written By: Mr. Jake R. Pomperada');
writeln;  
write('How many items ?  '); 
readln(num);
for a:= 1 to num do
begin
    write('Give value in item number ',a,' : ');
    read(list_items[a]);
end;
    writeln;
    writeln;
    writeln('Orignal Arrangement of Values : ');
    writeln;
for a:=1 to num  do
    write(list_items[a],' ');

{============ Selection Sort Ascending Order ===================}
For a:=1 to num-1 do
begin
Min:=a;
For b:= a to num do
begin
            If list_items[b] < list_items[min] then
            Min:=b;
End;
Temp:=list_items[a];
    list_items[a]:=list_items[min];
    list_items[min]:=temp;
End;

writeln;
writeln;
writeln('Arrangement of Values Using Selection Sort ');
writeln;
for a := 1 to num do
begin
write(list_items[a],' ');
end;

writeln;
writeln;
write('End of Program');
writeln;
readln;

End.



Bubble Sort in Turbo Pascal

A program that I wrote using Pascal as my programming language that will ask the user how many items to be sorted and then our program will display the original arrangement of the numbers and finally it will display the sorted arrangement of numbers on our screen. I am using bubble sort algorithm to sort the given numbers by our user. I am using Turbo Pascal for Windows as my programming environment. I hope you will find my work useful. Thank you.

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.






Sample Program Output


Program Listing

bubble.pas

Program Bubble_Sort;
uses Wincrt;

const
items = 100;

type
 values = array[1..items] of integer;

var
num,a,b  : integer;
list_items     : values;
min            : integer;
temp           : integer;


Begin
writeln;
writeln('Bubble Sort Program in Turbo Pascal');
writeln;
writeln;
writeln('Written By: Mr. Jake R. Pomperada');
writeln;  
write('How many items ?  '); 
readln(num);
for a:= 1 to num do
begin
    write('Give value in item number ',a,' : ');
    read(list_items[a]);
end;
    writeln;
    writeln;
    writeln('Orignal Arrangement of Values : ');
    writeln;
for a:=1 to num  do
    write(list_items[a],' ');

{============ Bubble Sort Ascending Order ===================}

for a:=1 to num-1 do
begin
     for b:= num downto a+1 do
     begin
          if list_items[b] < list_items[b-1] then
          begin
            Temp:=list_items[b];
            list_items[b]:=list_items[b-1];
            list_items[b-1]:=temp;
          end;
     end;
end;

writeln;
writeln;
writeln('Arrangement of Values Using Bubble Sort ');
writeln;
for a := 1 to num do
begin
write(list_items[a],' ');
end;

writeln;
writeln;
write('End of Program');
writeln;
readln;
End.



Thursday, September 14, 2017

Bucket Sort in Java

Here is the implementation of Bucket Sort using Java as my programming language. Our program will ask the user how many items to be sorted and then it will ask the user to give a series of numbers and then it will be sorted using selection sort algorithm. I hope you will find my work useful. 

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.





Sample Program Output


Program Listing

Bucket_Sorting.java

/**
 * 
 */
package bucket_sort;

import java.util.Scanner;

/**
 * @author Jake R. Pomperada
 * Bacolod City, Negros Occidental, Philippines
 * September 14, 2017  Thursday
*/


public class Bucket_Sorting {

/**
* @param args
*/
public int[] bucket_sort_demo(int[] array) {
    
   int[] bucket = new int[10000];   

 
   for (int i = 0; i < array.length; i++)
       bucket[array[i]]++;

   int outPos = 0;
   for (int i = 0; i < bucket.length; i++) { 
    if (bucket[i] > 0)
        array[outPos++] = i;
   }
    
   return array;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
 
Bucket_Sorting bSort = new Bucket_Sorting();      
System.out.print("\n\n");
System.out.print("===== Bucket Sort in Java ====");
System.out.print("\n\n");
System.out.print("===== Written By: Mr. Jake R. Pomperada =====");;
System.out.print("\n\n");
System.out.print("How many items? : ");
        int num = input.nextInt();
        int numbers[] = new int[num];

System.out.println();
        for (int i = 0; i < num; i++) {
            System.out.print ("Give value in item no. " + (i+1) + " : ");
            numbers[i] = input.nextInt();
        }

        System.out.print("\n\n");
System.out.print("Original Number Arrangements" );
System.out.print("\n\n");
        for (int temp : numbers){
        System.out.print(temp);
            System.out.print(", ");
        } 
        System.out.print("\n\n");
System.out.print("Sorted Number Arrangements" );
System.out.print("\n\n");
        
int[] sortedArray = bSort.bucket_sort_demo(numbers);
 
        for(int a:sortedArray){
            System.out.print(a);
            System.out.print(", ");
}
        input.close();
}

}




Wednesday, September 13, 2017

Merge Sort in Java

Here is the implementation of Merge Sort using Java as my programming language. Our program will ask the user how many items to be sorted and then it will ask the user to give a series of numbers and then it will be sorted using selection sort algorithm. I hope you will find my work useful. 

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.






Sample Program Output


Program Listing

/**
 * 
 */
package merge_sort;

import java.util.Scanner;

/**
 * @author Jake R. Pomperada
 * Bacolod City, Negros Occidental, Philippines
 * September 13, 2017   Wednesday
*/


public class Merge_Sorting {

/**
* @param args
*/
public static void merge_sort(int[] arr, int low, int high) 
    {
        int N = high - low;         
        if (N <= 1) 
            return; 
        int mid = low + N/2; 
        
        merge_sort(arr, low, mid); 
        merge_sort(arr, mid, high); 
        
        int[] temp = new int[N];
        int i = low, j = mid;
        for (int k = 0; k < N; k++) 
        {
            if (i == mid)  
                temp[k] = arr[j++];
            else if (j == high) 
                temp[k] = arr[i++];
            else if (arr[j]<arr[i]) 
                temp[k] = arr[j++];
            else 
                temp[k] = arr[i++];
        }    
        for (int k = 0; k < N; k++) 
            arr[low + k] = temp[k];         
    }
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
     
System.out.print("\n\n");
System.out.print("===== Merge Sort in Java ====");
System.out.print("\n\n");
System.out.print("===== Written By: Mr. Jake R. Pomperada =====");;
System.out.print("\n\n");
System.out.print("How many items? : ");
        int num = input.nextInt();
        int numbers[] = new int[num];

System.out.println();
        for (int i = 0; i < num; i++) {
            System.out.print ("Give value in item no. " + (i+1) + " : ");
            numbers[i] = input.nextInt();
        }

        System.out.print("\n\n");
System.out.print("Original Number Arrangements" );
System.out.print("\n\n");
        for (int temp : numbers){
        System.out.print(temp);
            System.out.print(", ");
        } 
        System.out.print("\n\n");
System.out.print("Sorted Number Arrangements" );
System.out.print("\n\n");
        
        
        merge_sort(numbers,0,num);
        for(int a:numbers){
            System.out.print(a);
            System.out.print(", ");
}
        input.close();

}

}