A simple program that I wrote using Java to ask the user to give two numbers and then our program will compute the difference between the two of them.
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
/*
* 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 diff_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 Diff_Two {
/**
* @param args the command line arguments
*/
public static int sub_two_number(int n1, int n2) {
int sub=0;
sub = (n1-n2);
return sub;
}
void display()
{
int num1=0, num2=0, sub_all=0;
Scanner s = new Scanner(System.in);
System.out.println();
System.out.println("=== Difference 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();
sub_all = sub_two_number(num1,num2);
System.out.println();
System.out.println("===== DISPLAY RESULTS ======");
System.out.println();
System.out.println("The difference betweem " + num1 + " and "
+ num2 + " is " + sub_all + ".");
System.out.println();
System.out.println("===== END OF PROGRAM ======");
System.out.println();
}
public static void main(String[] args)
{
// TODO code application logic here
Diff_Two demo = new Diff_Two();
demo.display();
}
}