Wap in java to find the number of two given number 6 and 5
Answers
Answered by
1
This is a Java Program to Accept two Integers and Check if they are Equal.
Enter two integer numbers as input. After that we match both the inputs with the help of equal to(==) operator. Hence we generate the output accordingly.
Here is the source code of the Java Program to Accept two Integers and Check if they are Equal. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;class AddNumbers{public static void main(String args[]){int x, y, z;System.out.println("Enter two integers to calculate their sum ");Scanner in = new Scanner(System.in );x = in.nextInt();y = in.nextInt();if(x>y)z = ( ( x*(x-1) )/2 ) - ( ( y*(y+1) )/2 ) ;else z = ( ( y*(y-1) )/2 ) - ( ( x*(x+1) )/2 ) ;System.out.println("Sum of numbers between the two numbers is ="+z);}}
Enter two integer numbers as input. After that we match both the inputs with the help of equal to(==) operator. Hence we generate the output accordingly.
Here is the source code of the Java Program to Accept two Integers and Check if they are Equal. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;class AddNumbers{public static void main(String args[]){int x, y, z;System.out.println("Enter two integers to calculate their sum ");Scanner in = new Scanner(System.in );x = in.nextInt();y = in.nextInt();if(x>y)z = ( ( x*(x-1) )/2 ) - ( ( y*(y+1) )/2 ) ;else z = ( ( y*(y-1) )/2 ) - ( ( x*(x+1) )/2 ) ;System.out.println("Sum of numbers between the two numbers is ="+z);}}
Similar questions
India Languages,
7 months ago
Environmental Sciences,
1 year ago
Physics,
1 year ago
Physics,
1 year ago
Physics,
1 year ago