Saturday, August 29, 2015

Average Grade Using One Dimensional Array in Java

In this example I wrote a program that will compute the average grade of the student on his or her several subjects using one dimensional array in Java the code is very simple to understand and use.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

/*
average_array.java
Programmer By: Mr. Jake R. Pomperada, MAED-IT
Date : July 23, 2015
Tools: NetBeans 8.0.2, Java SE 8.0

Problem No. 2:
  
Write a program that will ask the user to give eight grades for
eight subjects and then our program will find average grade of 
the student from the eight subjects.
*/
              

import java.util.Scanner;

class grade_array {
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
     String[] subjects = new String[]
     {"Computer", "Math", "English","Physical Education",
      "History","Science","Music and Arts","Filipino"};
     
  do { 
      int [] values; 
      values  = new int[8];  
      int x=0,average_grade=0,total_sum=0;
      System.out.print("Average Grade Solver");
      System.out.println();
      for (int a=0; a<8; a++)
      {
         x=1;
         x+=a;
         System.out.print("Enter your subject grade on " + subjects[a] + " : ");
         values[a] = input.nextInt();
         total_sum+=values[a];
         average_grade = total_sum/8;
      }
     System.out.println(); 
     System.out.println();
     System.out.print("Your average grade is 8 subject is " + average_grade + ".");
     System.out.println();
     System.out.print("\nDo you want to continue (Type y or n) : ");
     ch = input.next().charAt(0);                        
     } while (ch == 'Y'|| ch == 'y');  
     System.out.println();
     System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
     System.out.println("\n\n");
  }
} // End of Code

Odd and Even Numbers in Java Using One Dimensional Array

About this program that I wrote it will ask the user to enter a series of integer number and then the number is being stored in one dimensional array. Our program will enumerate the odd and even numbers based of the numbers given by our user.

If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

/*
odd_even_numbers_array.java
Programmer By: Mr. Jake R. Pomperada, MAED-IT
Date : July 23, 2015
Tools: NetBeans 8.0.2, Java SE 8.0

Problem No. 3:
  
Write a program that will ask the user to give ten numbers and then
the program will enumerate the odd and even numbers based on the 
given numbers by the user.
*/
              

import java.util.Scanner;

class odd_even_numbers_array {
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
        
  do { 
      int [] values; 
      values  = new int[10];  
      int x=0;
      System.out.print("ODD AND EVEN NUMBERS PROGRAMS");
      System.out.println();
      for (int a=0; a<10; a++)
      {
         x=1;
         x+=a;
         System.out.print("Enter value in item no. " + x + " : ");
         values[a] = input.nextInt();
        }       
         System.out.println(); 
         System.out.print("LIST OF EVEN NUMBERS");
         System.out.println();
      for (int a=0; a<10; a++)
      {
         if(values[a]%2 == 0) {
                System.out.print(" " + values[a]+ " ");
                }
      }        
      System.out.println(); 
      System.out.print("LIST OF ODD NUMBERS ");
      System.out.println(); 
      for (int a=0; a<10; a++)
      {
         if(values[a]%2 != 0) {
               System.out.print(" " + values[a]+ " ");
                }
      }     
     System.out.println("\n\n"); 
     System.out.print("\nDo you want to continue (Type y or n) : ");
     ch = input.next().charAt(0);                        
     } while (ch == 'Y'|| ch == 'y');  
     System.out.println();
     System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
     System.out.println("\n\n");
  }
} // End of Code
    



Sum and Average of Five Numbers Using Two Dimensional Array in Java

Two dimensional array is also known as matrix in Java in this article I would like to share with you a sample program that I wrote that demonstrate how to declare and use two dimensional array in Java programming language I called this program Sum and Average of Five Numbers Using Two Dimensional Array in Java.

What does the program will do is to ask the user to enter five numbers and then the program will compute the sum and average of the five numbers given by the user.

If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output


Program Listing

/*
average_sum_two_dimensional.java
Programmer By: Mr. Jake R. Pomperada, MAED-IT
Date : July 23, 2015
Tools: NetBeans 8.0.2, Java SE 8.0

Problem No. 1:
  
Write a program that will ask the user to give five numbers 
and then our program will find the total sum and average of
five numbers using two dimensional array.
*/


import java.util.Scanner;

class average_sum_two_dimensional {
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
   
  do { 
      int [][] values; 
      values  = new int[5][1];  
      int total_sum=0, average=0;
      System.out.print("Sum and Average of Five Numbers");
      System.out.println();
      for (int a=0; a<5; a++)
        for (int b=0; b<1; b++) {  
      {
        
         System.out.print("Enter value in item no." + (a+1) + " : ");
          
         values[a][b]= input.nextInt();
         total_sum += values[a][b];
         average = total_sum/5;
      }
    } 
     System.out.println(); 
     System.out.print("The total sum is " + total_sum + ".");
     System.out.println();
     System.out.print("The average of five numbers is " + average + ".");
     System.out.println();
     System.out.print("\nDo you want to continue (Type y or n) : ");
     ch = input.next().charAt(0);                        
     } while (ch == 'Y'|| ch == 'y');  
     System.out.println();
     System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
     System.out.println("\n\n");
  }
}


Sunday, August 16, 2015

Objects in JavaScript

In this article I would like to share with you sample program in JavaScript  that will teach you how to create an object and calling an object. Objects is a basic thing in Object Oriented Programming principle which contains properties and methods. The code is very simple and easy to understand.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.





Sample Program Output


Program Listing

<html>
    <head>
        <title> Objects in JavaScipt</title>
    <head>
        <style>
h1,h3  {
    font-family:arial;
color: blue;
   };
 </style>  
    <body>      
 <h1> Objects in JavaScript </h1>
 <br>
      <script>
            var person = {
                firstname : 'Jacob Samuel',
                lastname : ' Pomperada ',
                
                greet : function(persons_name) {
                    alert(' Hello ' + persons_name + ' How are you today? ');
                    },
                
                greet2 : function() {
                    alert('Hi ' + this.firstname  + ' ' +  this.lastname + ' God Bless you');
                } 
        };
            
            document.write('<h3> Persons First Name: ' + person.firstname + '</h3>');
            document.write('<br>');
            document.write('<h3> Persons Last Name: ' + person.lastname + '</h3>');
            person.greet('jacob');
person.greet2('jacob');
        </script>           
    </body>
</html>

If - Else If - Else Statement in JavaScript

In this article I would like to share with you how to use If - Else If - Else Statement in JavaScript. This is one of the most common conditional statement in JavaScript  that will make your program intelligent.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output


Program Listing

<html>
    <head>
        <title> If-Else If Statement</title>
    <head>
        
    <body>      
           
        <script>
           var age = 34;
            
            if (age < 18) {
                if (age > 0) 
{
                alert (" You are still a minor.");
}
                else {
     alert ("Sorry Invalid Age. Try Again !!!");
                     }
            } else if (age >= 18) 
   {
                alert ("You are already an Adult." )
                }
        </script>
</body>
</html>

Saturday, August 15, 2015

Function in JavaScript

In this article I will show you how to declare and use a function in Javascript. A function or method in other programming language like in Java is a module design to return a value. In our example I wrote a function named addition with two passing parameters that will be compute by our function.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output


Program Listing


<html>
    <head>
        <title> Function in JavaScript</title>
    <head>
        
    <body>
        
        
        <script>
            function addition(a, b) {
                    return a + b;
                                            }
            var sum = addition(10+5,5);
                                            
            alert("The total sum is " + sum + ".");
        </script>
   </body>
</html>

For Loop in JavaScript

In this article I would like to share for loop statement in Javascript. For loop statement is one of the most common looping statement in C/C++,Java,C# as well as JavaScript there are three parts in this loop statement first is the initialization of value, the second part is the condition and the third part is the increment or decrement.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.




Sample Program Output


Program Listing

<html>
    <head>
        <title> For Loop Statement in JavaScript</title>
    <head>
        
    <body      
      <font size='12' face='arial'> 
        <script>
           for(var a =1; a<=100; a++) {
               document.write(" "+a+ " ");
                        
                        
            }
        </script>
  </font>
   </body>
</html>

Wednesday, August 5, 2015

Bubble Sort in Java Program

In this article I would like to share with you one of the most common sorting algorithm used in computer science it is called bubble sort. Basically we use sorting to arrange the values in ascending or descending order. What our program does is to ask the user how many items to be sorted and then our program will ask the user to enter a series of values. After which our program will display the original values and it will display the ascending and descending order of values after it is processed by our program using bubble sort algorithm.

If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

// bubble_sort.java
// Written By: Mr. Jake R. Pomperada, BSCS, MAED-IT
// August 5, 2015   Wednesday
// Create a program that uses bubble sort algorithm with the following results.
//   BUBBLE SORT PROGRAM
//   How many values :6
//   Enter value in item no.1: 540
//   Enter value in item no.2: 313
//   Enter value in item no.3: 741
//   Enter value in item no.4: -456
//   Enter value in item no.5: 600
//   Enter value in item no.6: 341
//
//   BEFORE SORTING
//   540 313 741 -456 600 341 
//   AFTER SORTING
//
//   ASCENDING ORDER
//
 // -456 313 341 540 600 741
//   DESCENDING ORDER
//   741 600 540 341 313 -456
// THANK YOU FOR USING THIS PROGRAM


import java.util.Scanner;
class bubble_sort {
public static void main(String args[])  {
        
        Scanner scan = new Scanner(System.in);
        int items[] = null;
int values = 0;
       
        System.out.print("BUBBLE SORT PROGRAM");
        System.out.println();    
System.out.print("How many values :");
values = scan.nextInt();
        items = new int[values];

        for(int i=0; i<values; i++)
             {
            System.out.print("Enter value in item no." + (i+1) + ": ");     
            items[i] = scan.nextInt();
            }
        System.out.println();
System.out.print("BEFORE SORTING");
System.out.println();
for(int i=0; i<values; i++) 
              {
System.out.print(items[i] + " ");
     }
for(int i = 0; i < values; i++) {
 for(int j = 1; j < (values-i); j++) {
   if(items[j-1] > items[j]) {
        int temp = items[j-1];
                 items[j-1] = items[j];
items[j] = temp;
}
   }
}
        System.out.println();
System.out.println("AFTER SORTING");
        System.out.println();
System.out.println("ASCENDING ORDER");
        System.out.println();
for(int i=0; i<values; i++) 
         {
System.out.print(" " + items[i]);
}
        System.out.println();
System.out.print("DESCENDING ORDER");
         System.out.println();
for(int i=values-1; i>=0; i--)
        {
System.out.print(" " + items[i]);
}
       System.out.println("\n\n");
       System.out.print("\t THANK YOU FOR USING THIS PROGRAM"); 
       System.out.println();
    }
}



First Letter Capital Program in Java

As I continue my study on Java I have discovered that Java programming language has many built in functions that makes programming much easier and more fun specially we are working with strings. I enjoy every minute working with Java. No wonder there are many programmers, developers and software engineers find it very useful in many programming project because it is a very versatile programming language.

In this article I would like to share with you guys a sample program that I wrote in Java that will ask the user to give a sentence and then our  program will convert the first letter of the sentence into uppercase letter. I have created a method on it that well convert the first letter of the word in a give sentence by our user.  In addition our program it will ask the user if the user would want to repeat the program running by asking the user do you want to continue yes or not.
 
If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.
 
 
 
 
Sample Program Output 
 
 
Program Listing
 
 
// find_upper_case.java
// Programmer : Mr. Jake R. Pomperada, MAED-IT
// Date       : August 5, 2015
// Tools      : Netbeans 8.0.2
// Email      : jakerpomperada@yahoo.com and jakerpomperada@gmail.com
// Write a program that will conver the first letter of a word into capital
// letters


 import java.util.Scanner; 
  
 public class find_upper_case { 
  
public static String Upper_First_Letter(String str)
{
    boolean check_space = true;
    char[] chars = str.toCharArray();
    for (int a = 0; a < chars.length; a++) {
        if (Character.isLetter(chars[a])) {
            if (check_space) {
                chars[a] = Character.toUpperCase(chars[a]);   
            }
            check_space = false;
        } else {
            check_space = Character.isWhitespace(chars[a]);
        }
    }
    return new String(chars);
}
 
    public static void main(String[] args) {
     Scanner input = new Scanner(System.in);
     char ch;
                  
  do {
     String sentence,repeat;
     repeat = input.nextLine();
     System.out.print("FIRT LETTER CAPITAL PROGRAM");
     System.out.println();   
     System.out.print("Enter a Sentence : ");
     sentence = input.nextLine();
     System.out.println();
     System.out.println("ORIGINAL SENTENCE");
     System.out.print(sentence);
     System.out.println("\n\n");
     System.out.println("CONVERTED SENTENCE");
     System.out.print(Upper_First_Letter(sentence));
     System.out.println();
      System.out.print("\nDo you want to continue (Type y or n) : ");
     ch = input.next().charAt(0);                       
     } while (ch == 'Y'|| ch == 'y'); 
     System.out.println();
     System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
     System.out.println();
    }
}