Sunday, February 19, 2017

Quotient of Two Numbers in Java

In this sample program that I wrote it will ask the user to give two numbers and then our program will find the quotient of the two numbers and display the results on the screen using Java as our programming language.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package quotient_two;


import java.util.Scanner;

/**
 *
 * @authors Jake R. Pomperada and  Jacob Samuel F. Pomperada
 * Date : February 19, 2017  Sunday
 * Language : Java
 * IDE     : NetBeans
 */
public class Quotient_Two {

    /**
     * @param args the command line arguments
     */
   public static int div_two_number(int n1, int n2) {
      int div=0;
      
      div = (n1/n2);

      return div;
   } 
    void display()
    {
       int num1=0, num2=0, div_all=0;

        Scanner s = new Scanner(System.in);
     
        System.out.println();
        System.out.println("=== Quotient of Two Numbers Using Method in Java === ");
        System.out.println();
      
         System.out.print("Enter First Value : ");
         num1 = s.nextInt();
            
         System.out.print("Enter Second Value : ");
         num2 = s.nextInt();
                 
         div_all = div_two_number(num1,num2);
  
        System.out.println();
        System.out.println("===== DISPLAY RESULTS ======");
        System.out.println();
        System.out.println("The quotient betweem " + num1 + " and "
                     + num2 + " is " + div_all + ".");

        System.out.println();
        System.out.println("===== END OF PROGRAM ======");
        System.out.println();
    }
    
    public static void main(String[] args)
      {
        // TODO code application logic here
      Quotient_Two demo  = new Quotient_Two();
      demo.display();
            
    }
    
}






Difference Between Two Numbers in Java

A simple program that I wrote using Java to ask the user to give two numbers and then our program will compute the difference between the two of them.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package diff_two;


import java.util.Scanner;

/**
 *
 * @authors Jake R. Pomperada and  Jacob Samuel F. Pomperada
 * Date : February 19, 2017  Sunday
 * Language : Java
 * IDE     : NetBeans
 */
public class Diff_Two {

    /**
     * @param args the command line arguments
     */
   public static int sub_two_number(int n1, int n2) {
      int sub=0;
      
      sub = (n1-n2);

      return sub;
   } 
    void display()
    {
       int num1=0, num2=0, sub_all=0;

        Scanner s = new Scanner(System.in);
     
        System.out.println();
        System.out.println("=== Difference of Two Numbers Using Method in Java === ");
        System.out.println();
      
         System.out.print("Enter First Value : ");
         num1 = s.nextInt();
            
         System.out.print("Enter Second Value : ");
         num2 = s.nextInt();
                 
         sub_all = sub_two_number(num1,num2);
  
        System.out.println();
        System.out.println("===== DISPLAY RESULTS ======");
        System.out.println();
        System.out.println("The difference betweem " + num1 + " and "
                     + num2 + " is " + sub_all + ".");

        System.out.println();
        System.out.println("===== END OF PROGRAM ======");
        System.out.println();
    }
    
    public static void main(String[] args)
      {
        // TODO code application logic here
      Diff_Two demo  = new Diff_Two();
      demo.display();
            
    }
    
}





Addition of Two Numbers in Java

A simple program that I wrote using Java as my programming language that will ask the user to give two numbers and then our program will compute the sum of the two number being provided by our user.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

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

addition_two.java


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package addition_two;


import java.util.Scanner;

/**
 *
 * @authors Jake R. Pomperada and  Jacob Samuel F. Pomperada
 * Date : February 19, 2017  Sunday
 * Language : Java
 * IDE     : NetBeans
 */
public class addition_two {

    /**
     * @param args the command line arguments
     */
   public static int addition_two_number(int n1, int n2) {
      int sum=0;
      
      sum = (n1+n2);

      return sum;
   } 
    void display()
    {
       int num1=0, num2=0, sum_all=0;

        Scanner s = new Scanner(System.in);
     
        System.out.println();
        System.out.println("=== Addition of Two Numbers Using Method in Java === ");
        System.out.println();
      
         System.out.print("Enter First Value : ");
         num1 = s.nextInt();
            
         System.out.print("Enter Second Value : ");
         num2 = s.nextInt();
                 
         sum_all =  addition_two_number((num1,num2);
  
        System.out.println();
        System.out.println("===== DISPLAY RESULTS ======");
        System.out.println();
        System.out.println("The sum of " + num1 + " and "
                     + num2 + " is " + sum_all + ".");

        System.out.println();
        System.out.println("===== END OF PROGRAM ======");
        System.out.println();
    }
    
    public static void main(String[] args)
      {
        // TODO code application logic here
      addition_two demo  = new addition_two();
      demo.display();
            
    }
    
}

GCD and LCM of two integers using Euclids' Algorithm in Java


A simple program that I wrote using Java to solve the GCD and LCM of a given number of the user.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gcd_lcm;


import java.util.Scanner;

/**
 *
 * @authors Jake R. Pomperada and  Jacob Samuel F. Pomperada
 * Date : February 19, 2017  Sunday
 * Language : Java
 * IDE     : NetBeans
 */
public class gcd_lcm {

    /**
     * @param args the command line arguments
     */
    
    void display()
    {
       int num1=0, num2=0, gcd=0, lcm=0, remainder=0, numerator=0, denominator=0;

        Scanner s = new Scanner(System.in);
     
        System.out.println();
        System.out.println("===  GCD and LCM of two integers using Euclids' Algorithm in Java === ");
        System.out.println();
      
         System.out.print("Enter First Value : ");
         num1 = s.nextInt();
            
         System.out.print("Enter Second Value : ");
         num2 = s.nextInt();
                 
        if (num1 > num2)

        {
        numerator = num1;
        denominator = num2;
        }
    else

       {
        numerator = num2;
        denominator = num1;
       }

    remainder = numerator % denominator;

    while (remainder != 0)

    {

        numerator   = denominator;

        denominator = remainder;

        remainder   = numerator % denominator;

    }

    gcd = denominator;

    lcm = num1 * num2 / gcd;
  
        System.out.println();
        System.out.println("===== DISPLAY RESULTS ======");
        System.out.println();
        System.out.println("The GCD of " + num1 + " and "
                           + num2 + " is " + gcd + ".");

        System.out.println("The LCM of " + num1 + " and "
                           + num2 + " is " + lcm + ".");

        System.out.println();
        System.out.println("===== END OF PROGRAM ======");
        System.out.println();
    }
    
    public static void main(String[] args)
      {
        // TODO code application logic here
      gcd_lcm demo  = new gcd_lcm();
      demo.display();
            
    }
    
}




Summation of Odd and Even Numbers in Java

Here there I am very happy that more and move visitors visiting my site even though it is not earning but I am happy that more people benefited from my works and my friends works also who contribute their work in my website.

I this article I would like to share with you a sample program that will ask the user to give five numbers and then it will sum up all the odd and even numbers that the user given. I am using one dimensional array and methods in Java I hope you like my work. Thank you so much.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

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

sum_odd_even.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sum_odd_eve;


import java.util.Scanner;

/**
 *
 * @authors Jake R. Pomperada and Jacob Samuel F. Pomperada
 * Date : February 19, 2017  Sunday
 * Language : Java
 * IDE     : NetBeans
 */
public class sum_odd_even {

    /**
     * @param args the command line arguments
     */
    
    void display()
    {
         int val_items=0, total_sum_even = 0, total_sum_odd = 0;

        Scanner s = new Scanner(System.in);

        val_items =  5;
        int[] array_value = new int[val_items];

        System.out.println();
        System.out.println("=== SUMMATION OF ODD AND EVEN NUMBERS IN JAVA === ");
        System.out.println();
        for(int b = 0; b < val_items; b++)

        {
           System.out.print("Enter value in item no. " + (b+1) + " : ");
            array_value[b] = s.nextInt();
       }

        for(int b = 0; b < val_items; b++)

        {
            if(array_value[b] % 2 == 0)

            {

                total_sum_even +=  array_value[b];

            }

            else

            {

                total_sum_odd += array_value[b];
            }

        }
        System.out.println();
        System.out.println("===== DISPLAY RESULTS ======");
        System.out.println();
        System.out.println("The Total Sum  of Even Numbers is "
                  + total_sum_even + ".");

        System.out.println("The Total Sum  of Odd Numbers is "
                  + total_sum_odd + ".");
        System.out.println();
        System.out.println("===== END OF PROGRAM ======");
        System.out.println();
    }
    
    public static void main(String[] args)
      {
        // TODO code application logic here
      sum_odd_even demo  = new sum_odd_even();
      demo.display();
            
    }
    
}







Thursday, February 16, 2017

Largest of Three Numbers in C

In this article I would like to share with you a sample program that I wrote using C as my programming language that will ask the user to give three numbers and then our program will check and determine which of the three numbers is the largest in terms of value using if conditional statement in C.  The code is very easy to understand and use. I am using CodeBlocks as my text editor and Dev C++ as my C/C++ compiler in this sample program. Thank you.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

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

#include <stdio.h>

int main()
{
    int a=0,b=0,c=0;

    printf("\n\n");
    printf("LARGEST OF THREE NUMBERS IN C");
    printf("\n\n");
    printf("Give three numbers : ");
    scanf("%d%d%d",&a,&b,&c);
    printf("\n\n");
     if (a>b) {
         if (a>c){
            printf("The Largest Number is %d",a);
         }
         else {
            printf("The Largest Number is %d",c);
         }
     }
         else if (b>c){
            printf("The Largest Number is %d",b);
         }
         else {
            printf("The Largest Number is %d",c);
         }
    printf("\n\n");
    printf("END OF PROGRAM");
    printf("\n\n");
     }


Factors of a Number in C

Hi there in this article I would like to share with you guys a sample program that I wrote using C as my programming language. Our program will ask the user to give a number and then our program will display the factors of the given number using For loop statement in C. The code is very short and easy to understand. I hope you will learned from it. Thank you.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

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

#include <stdio.h>

int main()
{
    int number=0,a=0;

    printf("\n\n");
    printf("FACTORS OF A NUMBER IN C");
    printf("\n\n");
    printf("Give any integer number : ");
    scanf("%d",&number);
    printf("\n\n");
    printf("The Factors of %d are: ",number);
     for (a=1; a<=number; a++){
         if (number % a == 0){
            printf(" %2d ",a);
         }
     }
    printf("\n\n");
    printf("END OF PROGRAM");
    printf("\n\n");
}