Tuesday, November 16, 2021

Addition of Two Numbers Using OOP in Java

 A simple addition of two number using OOP (Object-Oriented Programming) approach in Java programming language.

 I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Program Listing

package test;


import java.util.Scanner;

class  Addition_OOP {

    public int val_a;

    public int val_b;

    public int sum;

    

    static Scanner input = new Scanner(System.in);

    

public void getdata() {

  

  System.out.println("\n");

  System.out.print("Addition of Two Numbers Using OOP in Java ");

  System.out.println("\n");

  System.out.print("Give First Value  : ");

  val_a = input.nextInt();

  System.out.print("Give Second Value :  ");

  val_b = input.nextInt();

 

 }

 

  public void calculate(){

     sum =(val_a + val_b);

  }

          

 

 public void display() {

  System.out.println();

  System.out.println("The sum of " + val_a + " and "

          + val_b + " is " + sum + ".");

  System.out.println();

  System.out.println("End of Program");

  

 }

 

 public static void main(String args[]) {

  Addition_OOP add = new Addition_OOP();

  add.getdata();

  add.calculate();

  add.display();

  input.close();

 }

}

No comments:

Post a Comment