Sunday, May 14, 2017

Leap Year Checker in Java OOP Using Getters and Setters

Here is a sample program that I wrote using Java to check if the given year is a leap year or not a leap year using object oriented programming approach. The code is very easy to understand and use.

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 demo;

import java.util.Scanner;

class CheckLeapYear {
public int YearGiven=0;


public CheckLeapYear(int Year)
{
YearGiven = Year;
}
public int getYearGiven() {
return YearGiven;
}

public void setYearGiven(int Year) {
YearGiven = Year;
}
public void displayResult()
{
 
   if((YearGiven % 400 == 0) || ((YearGiven % 4 == 0) && (YearGiven % 100 != 0))) {
   System.out.println();
System.out.print("The year " + YearGiven + " is a LEAP YEAR.");
   System.out.println("\n\n");
   System.out.print("===== END OF PROGRAM ======");
   System.out.println();
   }
           else {
        System.out.println();
    System.out.print("The year " + YearGiven + " is NOT LEAP YEAR.");
       System.out.println("\n\n");
       System.out.print("===== END OF PROGRAM ======");
       System.out.println();
           }
}
}
public class LeapYear {

/* Written By: Mr. Jake R. Pomperada, MAED-IT  */
/* Java                                        */
/* May 14, 2017    Sunday                      */
public static void main(String[] args) {
 Scanner input = new Scanner(System.in);
 int Year=0;
 
 System.out.println();
     System.out.println("Leap Year Checker in JAVA OOP");
     System.out.println();
     System.out.print("What is the year ? :  ");
     Year = input.nextInt();
     
     CheckLeapYear Given_Year = new CheckLeapYear(Year);
     
     Given_Year.displayResult();
     input.close();
}

}



CRUD in C# Using MS SQL Server and Entity Framework

In this article I would like to share it  again the work of one of my best friend and fellow software engineer Mr. Dave Marcellana From Talisay City, Negros Occidental Philippines. This sample program will show you how to created an CRUD application using Microsoft SQL Server and Entity Framework. He is using Microsoft Visual Studio 2017 in written this application.

 We are thankful that Dave us this work to benefit all of us.  Thanks Dave.




Sample Program Output




Power of a Number in Java OOP

Here is a simple program to demonstrate Object Oriented Programming in Java I called this program power of a number. It will ask the user to give base and exponent value and then our program will compute its power value. The code is written in object oriented programming format and easy to understand. 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 demo;

import java.util.Scanner;


class check_power {
public double val_base,val_exponent;
public check_power(double base, double exponent)
{
val_base = base;
val_exponent = exponent;
}
public void set_power(double base, double exponent) {
val_base = base;
val_exponent = exponent;
}
public double get_base(double base) {
return(val_base);
}
public double get_exponent(double exponent) {
return(val_exponent);
}
public void displayResult()
{
 
            double results = Math.pow(val_base,val_exponent);
   System.out.println();
System.out.print("The Power value is " + results + ".");
   System.out.println("\n\n");
   System.out.print("===== END OF PROGRAM ======");
   System.out.println();
}
}


public class power_number {

public static void main(String[] args) {
   
int a=0,b=0;
 Scanner input = new Scanner(System.in);
 System.out.println();
     System.out.println("Power Number Solver in JAVA OOP");
     System.out.println();
     System.out.print("Give Base Value : ");
     a = input.nextInt();
     System.out.print("Give Exponent Value : ");
     b = input.nextInt();
   
     check_power solve = new check_power(a,b);
     
     solve.displayResult();
     input.close();

}

}





Saturday, May 13, 2017

Positive and Negative Number Checker in Java OOP Using Setter's and Getter's

I very simple program in Java that will ask the user to give a number and then our program will check and determine if the the given number is a positive or negative number using getters and setters in Java. The code is very short and easy to understand.  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 demo;

import java.util.Scanner;


class check_value {
public int val_number;
public check_value(int a)
{
val_number = a;
}
public void setCheck_value(int a) {
val_number = a;
}
public int getCheck_value() {
return(val_number);
}
public void displayResult()
{
if (val_number >=0) {
   System.out.println();
System.out.print("The given number " + val_number + " is a Positive Number.");
   System.out.println("\n\n");
   System.out.print("===== END OF PROGRAM ======");
   System.out.println();
}
else {
System.out.println();
    System.out.print("The given number " + val_number + " is a Negative Number.");
System.out.println("\n\n");
System.out.print("===== END OF PROGRAM ======");
System.out.println();
}
}
}

public class Positive_Negative_Numbers {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int b=0;
 System.out.println();
     System.out.println("POSITIVE AND NEGATIVE NUMBER CHECKER IN JAVA OOP");
     System.out.println();
     System.out.print("Give a Number : ");
     b = input.nextInt();
   
    check_value num_values = new check_value(b);
 num_values.displayResult();
    
    
     input.close();
}

}

Tuesday, May 9, 2017

Student Information Using Inheritance in Java

Here is a very simple program that I wrote using Java as my programming language that demonstrate how to use inheritance. The program will display student information on the screen. I hope you will learn something out of it.  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 demo;


class Student {
String name="Mario Chua";
String course="Bachelor of Science in Business Management";
int age=17;
}

public class inheritance extends Student {
String school="Manila State University";
double tuition= 45600.51;

public static void main(String[] args) {
inheritance studs = new inheritance();
System.out.println();
        System.out.println("Student Information Using Inheritance in Java");
        System.out.println();
System.out.println("Student Name : " + studs.name);
System.out.println("Course       : " + studs.course);
System.out.println("Age          : " + studs.age);
System.out.println("School       : " + studs.school);
System.out.println("Tuition Fee  : Php " + studs.tuition);
}

}






Monday, May 8, 2017

Payroll Program in Java Using Getters and Setters


In this article I would like to share with you a simple payroll program that I wrote using Java it is an object oriented programming style with the use of getters and setters a concept of encapsulation and the creation of object. The code is very simple and easy to understand. I hope you will find my work useful. 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 demo;

import java.util.Scanner;

public class Payroll {
int rate_per_day=0, no_of_days=0,emp_id=0;
String employees_name;
private int getRate_per_day() {
return rate_per_day;
}

private int getNo_of_days() {
return no_of_days;
}

private int getEmp_id() {
return emp_id;
}

private String getEmployees_name() {
return employees_name;
}

private void setRate_per_day(int rate_per_day) {
this.rate_per_day = rate_per_day;
}

private void setNo_of_days(int no_of_days) {
this.no_of_days = no_of_days;
}

private void setEmp_id(int emp_id) {
this.emp_id = emp_id;
}

private void setEmployees_name(String employees_name) {
this.employees_name = employees_name;
}

public int process_Salary() {
return(no_of_days * rate_per_day);
}
public void display_Records(){
   System.out.println();
         System.out.println("===== DISPLAY RESULTS =====");
   System.out.println();
    System.out.println("Employee's ID         : "  + getEmp_id());
    System.out.println("Employee's Name       : "  + getEmployees_name());
    System.out.println("Number of Day's Work  : "  + getNo_of_days());
    System.out.println("Rate Per Day          :  " + getRate_per_day());
       System.out.println();
       System.out.println("Gross Salary          : Php " + process_Salary());
       System.out.println();
       System.out.print("\t END OF PROGRAM");
}

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
 
  Payroll emp = new Payroll();
  
      System.out.println();
      System.out.println("Payroll Program in Java Using Getters and Setters");
      System.out.println();
      System.out.print(" Employee's ID Number : ");
      emp.emp_id = input.nextInt();
      input.nextLine();
      System.out.print(" Employee's Name : ");
      emp.employees_name = input.nextLine();
       System.out.print(" Employee's Daily Rate : ");
      emp.rate_per_day = input.nextInt();
       System.out.print(" Number of Day's Work : ");
      emp.no_of_days = input.nextInt();
  
      emp.setEmp_id(emp.emp_id);
      emp.setEmployees_name(emp.employees_name);
      emp.setNo_of_days(emp.no_of_days);
      emp.setRate_per_day(emp.rate_per_day);
      
      emp.getEmp_id();
      emp.getEmployees_name();
      emp.getNo_of_days();
      emp.getRate_per_day();
      
       emp.display_Records();
  
input.close();

}

}



Sunday, May 7, 2017

Constructor in Java

Here is a very simple implementation of constructor in Java. Constructor is very important in creating an object in object oriented programming in Java. The code is very short and easy to understand. 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 demo;

class Car {
 void Model_Car() {
System.out.println();
System.out.println("Constructor Demo in Java");
System.out.println();
System.out.println("I am driving a Toyota Corolla Model 2017.");
  }
}

public class Constructor {

public static void main(String[] args) {
    
    Car Toyota = new Car();
       
    Toyota.Model_Car();

}

}

Addition of Five Numbers in Java Using Getters and Setters

Here is a sample program that I wrote using Java to ask the user to give five numbers and then our program will compute for the total sum of the five numbers given by our user. I'm using object oriented approach and using getters and setters in Java. I hope you will find my work useful. I am using Eclipse Neon as my text editor and Jave 8 as my version of Java. 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

Addition.java

package demo;

import java.util.Scanner;

public class Addition {

public int a=0,b=0,c=0,d=0,e=0;
private int getA() {
return a;
}
private void setA(int a) {
this.a = a;
}
private int getB() {
return b;
}
private void setB(int b) {
this.b = b;
}
private int getC() {
return c;
}
private void setC(int c) {
this.c = c;
}
private int getD() {
return d;
}
private void setD(int d) {
this.d = d;
}
private int getE() {
return e;
}
private void setE(int e) {
this.e = e;
}
public int getResults(){
return(a+b+c+d+e);
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Addition val = new Addition(); 
  
       System.out.println();
       System.out.println("Addition of Five Numbers in Java Using Getters and Setters");
       System.out.println();
       System.out.print("Enter first value : ");
       val.a = input.nextInt();
       System.out.print("Enter second value : ");
       val.b = input.nextInt();
       System.out.print("Enter third value : ");
       val.c = input.nextInt();
       System.out.print("Enter fourth value : ");
       val.d = input.nextInt();
       System.out.print("Enter fifth value : ");
       val.e = input.nextInt();
   val.setA(val.a);
   val.setB(val.b);
   val.setC(val.c);
   val.setD(val.d);
   val.setE(val.e);
     
   val.getA();
   val.getB();
   val.getC();
   val.getD();
   val.getE();
   
   val.getResults();
   
 System.out.println();
        System.out.print("The total sum is " + val.getResults() + ".");
        System.out.println("\n");
        System.out.print("\t END OF PROGRAM");
        input.close();
}

}