A simple program to ask the user to give two numbers and then the program will compute the difference of two numbers without using subtraction operator 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 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.

Program Listing

import java.util.Scanner;

public class subtract_two_numbers {

	
	public static void main(String[] args) {
		
	   int val1=0,val2=0;
	   
		Scanner input_val= new Scanner(System.in);
		
		  System.out.println("\n");
		  System.out.println("\tSubtraction of Two Numbers Without Using Subtraction Operator in Java");
		  System.out.println("\n");
	      System.out.print("\tEnter the first number  : ");
	      val1=input_val.nextInt();
	      System.out.print("\tEnter the second number : ");
	      val2=input_val.nextInt();
	      
	      int subtract = val1+(~val2+1);
	  
	      System.out.println("\n");
		  System.out.println("\tThe difference between " + val1 +
	    		   " and " + val2+ " is " + subtract + ".");
		  System.out.println("\n");
		  System.out.println("\tEnd of Program");
		  System.out.println("\n");
		  input_val.close();
}

}