Showing posts with label addition of two numbers in java. Show all posts
Showing posts with label addition of two numbers in java. Show all posts

Wednesday, October 23, 2019

Addition of Two Numbers in Java

I write a program using Java as my programming language that will ask the user to give two numbers and then the program will compute the sum of two numbers and display the results on the screen.

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 in 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.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.




Sample Program Output



Program Listing

addition.java

/**
 * 
 */
package addition;

/**
 * @author Jacob
 *
 */

import java.util.Scanner;

public class addition {

/**
* @param args
*/
public static void main(String[] args) {
Scanner inputs = new Scanner(System.in);
System.out.print("\n\n");
System.out.print("\tAddition of Two Numbers");
System.out.print("\n\n");
System.out.print("\tGive First Value : ");
int a = inputs.nextInt();
System.out.print("\tGive Second Value : ");
int b = inputs.nextInt();
int sum = (a+b);
System.out.print("\n");
System.out.print("\tThe sum of " + a + " and "
   + b + " is " + sum +".");
System.out.print("\n\n");
System.out.print("\tEnd of Program");
}

}

Sunday, February 19, 2017

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();
            
    }
    
}

Tuesday, December 15, 2015

addition of two numbers in java

This sample program that I wrote in Java will compute the total of two numbers using applet as our graphical user interface. I used this code as one of my programming laboratory activities during the time I working as college professor. I hope you will find my work useful in your quest to learn Java programming.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


  

Sample Program Output


Program Listing

    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.Label;

    public class add extends Applet implements ActionListener{
      TextField text1,text2,output;
      Label label1,label2,label3,title;
      Button button,clear;
      public void init(){
        setLayout(null);


          title = new Label("Addition of Two Numbers");
          title.setBounds(80,10,140,20);
          add(title);
          title.setAlignment(title.CENTER);

        label1 = new Label("Enter Number 1: ");
        label1.setBounds(20,50,100,20);
        add(label1);

        text1 = new TextField(5);
        text1.setBounds(150,50,100,20);
        add(text1);

        label2 = new Label("Enter Number 2: ");
        label2.setBounds(20,90,100,20);
        add(label2);

        text2 = new TextField(5);
        text2.setBounds(150,90,100,20);
        add(text2);

        label3 = new Label("Sum of Two Numbers: ");
        label3.setBounds(20,130,130,20);
        add(label3);

        output = new TextField(5);
        output.setBounds(150,130,100,20);
        add(output);

        button = new Button("Sum");
        button.setBounds(150,170,100,20);
        add(button);

        clear = new Button("Clear");
        clear.setBounds(280,170,100,20);
        add(clear);

        button.addActionListener(this);
        clear.addActionListener(this);


        }
        public void actionPerformed(ActionEvent ae){
        int num1=Integer.parseInt(text1.getText());
        int num2=Integer.parseInt(text2.getText());
        int sum=num1+num2;
        output.setText(Integer.toString(sum));
            if(ae.getSource() == clear)
            {
                 text1.setText("");
              text2.setText("");
               output.setText("");
               text1.requestFocus();
    }
}
}