Tuesday, July 7, 2015

Highest and Smaller Number in Java

One of the most interesting problem in programming is to ask the user to enter a series of number and then our program will determine which of the given number is the smallest and the highest number from the series of number by the user. Normally the data structure that we will use in this problem is array to be specific one dimensional array so to speak and then we will use for loop statement and if statement to compare each numbers and to check which of the given number is the smallest and highest.

I called this program Highest and Smallest Number in Java what the program does is to prompt or ask the user how many numbers to be accepted and to be process. After the user provide the values in our program it will compare and determine what is the smallest and the highest in a given list of values.

The program is very simple and easy to understand. I hope you will find my work useful in learning how to program in Java. 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 my mobile number 09173084360.


Thank you very much and Happy Programming.



Sample Program Output

Program Listing

// smallest_biggest_number.java
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Date : July 7, 2015
// Email Address: jakerpomperada@yahoo.com
//                            jakerpomperada@gmail.com

// Problem : Write a program in Java that will check what is the highest and
//           lowest number given by the user using one dimensional array.

import java.util.Scanner;  

public class smallest_biggest_number {
    
    public static void main(String[] args) {

        Scanner input=new Scanner(System.in);
       
        int[] num= new int[10];
       
       System.out.print("\t\t    SMALLEST AND HIGHEST NUMBER ");
       System.out.print("\n\n");
       System.out.print("How many items ? : ");
       int n=input.nextInt();
       int smallest = Integer.MAX_VALUE;
       int biggest =Integer.MIN_VALUE;
      
       for(int i =0;i<n;i++) {
            int y=i+1;
            System.out.print("Enter item value no. " + y  + " value : ");
            num[i]=input.nextInt();
            if(num[i] < smallest) {

             smallest = num[i];

            }
            if (num[i] > biggest) {
                biggest = num[i];
               }

        }
       System.out.println();
       System.out.println("The Smallest number is  " +smallest + ".");
       System.out.println("The Biggest number is   " +biggest +".");
       System.out.println();
       System.out.println("\t\t END OF PROGRAM");     
       System.out.println("\n\n");
    }

}



Multiplication Table in Java

In this short article I would like to share with you a program that I wrote using Java as my programming language I called this program multiplication table. What the program does is that it will display a multiplication table on the screen very similar that is being used in elementary mathematics.  

I hope you will find my work useful in learning how to program in Java. 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 my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

// multiplication_table.java
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Date : July 7, 2015
// Email Address: jakerpomperada@yahoo.com
//                jakerpomperada@gmail.com

public class multiplication_table {
    public static void main(String[] args) {

        int Table_Size = 10;

      Display(Table_Size);
    }
   
    public static void Display(int Table_Size) {

        System.out.print("\t\t    MULTIPLICATION TABLE ");
        System.out.print("\n\n");
        System.out.format("      ");

        for(int i = 0; i<=Table_Size ;i++ ) {

            System.out.format("%4d",i);

        }

        System.out.println();

       System.out.println(" -------------------------------------------------");

        
        for(int i = 0 ;i<=Table_Size ;i++) {

             System.out.format("%4d |",i);

            for(int j=0;j<=Table_Size ;j++) {

                System.out.format("%4d",i*j);

            }

            System.out.println();

        }
   System.out.println("\n");
   System.out.println("\t\t END OF PROGRAM");     
   System.out.println("\n\n");
    }
}


Sunday, June 28, 2015

Reverse a Number in Java Version 2

A simple program that will ask the user to enter a number and then it will reverse the arrangement of number given by the user.The code is very simple but it uses already the concepts of object oriented programming.

I hope you will find my work  useful in a sense the logic of programming is also applied 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 my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

import java.util.Scanner;


class reverse_number {
    public int reverse_given_number(int number)
    {
         
        int reverse = 0;
        while(number != 0){
            reverse = (reverse*10)+(number%10);
            number = number/10;
        }
        return reverse;
    }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
do
    {
  // creating of value object
  
   reverse_number value = new reverse_number();
      
  System.out.println();
  System.out.println("===== REVERSE A NUMBER =====");
  System.out.println();
  System.out.print("Enter a Number :  ");
  int number_value =   scan.nextInt();
  
  System.out.println();

  System.out.print("The given number is " + number_value + 
  " it's reverse order will be " +value.reverse_given_number(number_value)+ ".");
    System.out.println("\n\n");
    System.out.print("Do you Want To Continue (Y/N) :=> ");
    a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
          System.out.println("\n");
          System.out.println("\t ===== END OF PROGRAM ======");
         System.out.println("\n");
 }
  
   } // End of Program



Basic Math Operations in Java

A simple program that I wrote that I called Basic Math Operations in Java that will show you basic mathematical operations like addition, subtraction, multiplication and division using Java programming language.The code is very simple but it uses already the concepts of object oriented programming.

I hope you will find my work  useful in a sense the logic of programming is also applied 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 my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

import java.util.Scanner;


class basic_math {
    public static int math_operations(int a, int b)
    {
       int sum = (a + b);
       int difference = (a-b);
       int product = (a * b);
       int quotient = (a/b);
       
      System.out.println("The sum of " + a + " and " + b + " is " + sum +".");
      System.out.println("The difference of " + a + " and " + b + " is " + difference +".");
      System.out.println("The product of " + a + " and " + b + " is " + product +".");
      System.out.println("The quotient of " + a + " and " + b + " is " + quotient +".");
      return 0;
     }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
  do
    {
    System.out.println();
    System.out.println("===== BASIC MATH OPERATIONS =====");
    System.out.println();
    System.out.print("Enter two numbers : ");
    int x = scan.nextInt();
    int y = scan.nextInt();
      
     math_operations(x,y); 

    System.out.println("\n");
    System.out.print("Do you Want To Continue (Y/N) :=> ");
    a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
     System.out.println("\n");
     System.out.println("\t ===== END OF PROGRAM ======");
     System.out.println("\n");
   }
  
  }  // End of Program


Money Bills Denomination Counter in Java

A simple program that I wrote in Java that will count how many money bills in a given amount of money. It uses % or modulo operator of Java to achieve its results.The code is very simple but it uses already the concepts of object oriented programming.

I hope you will find my work  useful in a sense the logic of programming is also applied 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 my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

import java.util.Scanner;


class bills{
    public static int count_bills(int amount)
    {
   int solve_thousand=0,solve_five=0,solve_two=0,solve_one=0;
   int remainder_thousand=0,remainder_five=0;
   int remainder_two=0,remainder_one=0;

   solve_thousand =(amount/ 1000);
   remainder_thousand = solve_thousand % 1000;

   solve_five =(amount/ 500);
   remainder_five = solve_five % 500;

   solve_two =(amount/ 200);
   remainder_two = solve_two % 200;

   solve_one =(amount/ 100);
   remainder_one= solve_one % 200;
   
   System.out.println("\n");
   System.out.println("Number of Php 1000 Bill(s) :=> " +  remainder_thousand);
   System.out.println("Number of Php 500  Bill(s) :=> " +  remainder_five);
   System.out.println("Number of Php 200  Bill(s) :=> " +  remainder_two);
   System.out.println("Number of Php 100  Bill(s) :=> " +  remainder_one);
   return 0;
   }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
  do
    {
    System.out.println();
    System.out.println("===== MONEY BILLS DENOMINATION COUNTER =====");
    System.out.println();
    System.out.print("Enter the Amount : Php  ");
    int amount = scan.nextInt();

    count_bills(amount);      
    System.out.println("\n");
    System.out.print("Do you Want To Continue (Y/N) :=> ");
    a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
     System.out.println("\n");
     System.out.println("\t ===== END OF PROGRAM ======");
     System.out.println("\n");
   }
  
  }  // End of Program




Armstrong Checker in Java

A simple program that I wrote using Java programming language that will check if the number given by the user is an armstrong number or not. The code is very simple but it uses already the concepts of object oriented programming.

I hope you will find my work  useful in a sense the logic of programming is also applied 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 my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

import java.util.Scanner;


class armstrong_checker {
    public int check_armstrong_number(int value)
    {
       int temp = value;
int sum = 0;
int mod = 0;
while(temp != 0) {
mod = temp % 10;
sum = sum + (mod * mod * mod);
temp = temp / 10;
}
if(sum == value) 
System.out.println("The given number " + value + " is  Armstrong Number.");
else
System.out.println("The given number " + value + " is Not an Armstrong Number.");
    return 0;
    }


public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
do
    {
  // creating of an object
  
  armstrong_checker number = new armstrong_checker();
      
  System.out.println();
  System.out.println("===== ARMSTRONG NUMBER CHECKER =====");
  System.out.println();
  System.out.print("Enter a Number :  ");
  int number_given =   scan.nextInt();
  
  System.out.println();
  number.check_armstrong_number(number_given);
  System.out.println("\n\n");
  System.out.print("Do you Want To Continue (Y/N) :=> ");
   a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
          System.out.println("\n");
          System.out.println("\t ===== END OF PROGRAM ======");
         System.out.println("\n");
 }
  
   } // End of Program


















Average Quizzes Solver in Java

This is a very simple program that will compute the average quizzes of the student based on five quizzes given by their teacher that I wrote in Java programming language. The code is very simple but it uses already the concepts of object oriented programming.

I hope you will find my work  useful in a sense the logic of programming is also applied 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 my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

import java.util.Scanner;


class five_test {
    public int find_five_average(int a, int b, int c, int d, int e)
    {
        int average=0;
        average=(a+b+c+d+e)/5;
        return(average);     
    }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
do
    {
  // creating of an quizzes object
  
  five_test quizzes = new five_test();
      
  System.out.println();
  System.out.println("===== AVERAGE QUIZZES SOLVER =====");
  System.out.println();
  System.out.print("Enter Score on Quiz Number 1 :  ");
  int quiz_one =   scan.nextInt();
  System.out.print("Enter Score on Quiz Number 2 :  ");
  int quiz_two=   scan.nextInt();
  System.out.print("Enter Score on Quiz Number 3 :  ");
  int quiz_three =   scan.nextInt();
  System.out.print("Enter Score on Quiz Number 4 :  ");
  int quiz_four =   scan.nextInt();
  System.out.print("Enter Score on Quiz Number 5 :  ");
  int quiz_five =   scan.nextInt();
  
  System.out.println();

  System.out.print("The total average of five quizzes is " +
  quizzes.find_five_average(quiz_one,quiz_two,quiz_three,quiz_four,quiz_five)+  ".");
  System.out.println("\n\n");
  System.out.print("Do you Want To Continue (Y/N) :=> ");
   a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
          System.out.println("\n");
          System.out.println("\t ===== END OF PROGRAM ======");
         System.out.println("\n");
 }
  
   } // End of Program



Triangle Pattern in Java

A simple program that I wrote in Java that will display a triangle pattern on the screen using for loop statements.

I hope you will find my work  useful in a sense the logic of programming is also applied 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 my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output


Program Listing

class pattern_one {

  public static void main(String args[]) {
 int a=10;
 int b=1;
 System.out.println("\n\n");
 System.out.print("TRIANGLE PATTERN ONE");
 System.out.println("\n\n");
 for(int i=1; i<=a; i++)
 {
  for (int j=a-1;j>=i; j--)
  {
  System.out.print(" ");
  }
   for (int k=1; k<=b; k++){
    System.out.print("*");
   }
 b++;
System.out.println();
 }
}

  } // End of Program


Inches To Centimeter Converter in Java

In this article I would like to share with you a sample program that I wrote in Java programming language Inches To Centimeter Converter.  The program will ask the user to enter a value in inches and then it converted it to its centimeter equivalent.  

I hope you will find my work  useful in a sense the logic of programming is also applied 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 my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

import java.util.Scanner;
import java.text.DecimalFormat;


class inches_to_centimeter
{

  public static double convert_to_centimeters(double inches)
   {
   double solve_centimeters = (inches * 2.54);
   return(solve_centimeters);
   }


 public static void main(String args[])
 {
     Scanner scan = new Scanner(System.in);
     DecimalFormat df = new DecimalFormat("###.##");
      char a;

  do
    {

    System.out.print("\n");
    System.out.println("==============================================");
    System.out.println("||    <<< Inches To Centimeter Converter  >>>  ||");
    System.out.println("==============================================");
    System.out.print("\n");
    System.out.print("How many length in inches? :=> ");
      double get_inches =   scan.nextDouble();

    System.out.println("\n");
    System.out.println("=======================");
    System.out.println("||  DISPLAY RESULT   ||");
    System.out.println("=======================");
    System.out.println("\n");
    System.out.print("The given length in inches is " + df.format(get_inches) + 
  " the equivalent length in centimeters is " +df.format(convert_to_centimeters(get_inches))+ " cms.");
    System.out.println("\n\n");
    System.out.print("Do you Want To Continue (Y/N) :=> ");
    a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
          System.out.println("\n");
          System.out.println("\t ===== END OF PROGRAM ======");
         System.out.println("\n");
 }
} // End of Program