Example:

package javaapplication;

import java.util.Scanner;

/**
 *
 * @author Rathorji
 */
public class JavaApplication {

    /**
     * @param args the command line arguments
     */

    public static void main(String[] args) {
        int p, q, r;
        System.out.println("Enter two integers to calculate their sum: ");
        Scanner sc = new Scanner(System.in); //keyboard input .
        p = sc.nextInt(); //scan data for input of integer value
        q = sc.nextInt();
        r = p - q;
        System.out.println("Sum of entered integers = " + r);

    }

}



output:

run:
Enter two integers to calculate their sum:
30
20
Sum of entered integers = 10