Question: Write a Java program to compare two numbers.
Input Data:
Input first integer: 25
Input second integer: 39
Expected Output
25 != 39 25 < 39 25 <= 39
Ans:package learning;
import java.util.Scanner;
public class learnNew {
// 25 != 39
// 25 < 39
// 25 <= 39
public static void main(String[] args){
Scanner scan = new Scanner(System.in) ;
int first = 25;
int second = 39;
if(first != second) {
System.out.println(first + "!=" + second);
}
else {
System.out.println(first + "==" + second);
} if (first < second){
System.out.println(first + "<" + second);
} else {
System.out.println(first + ">" + second);
} if (first <= second){
System.out.println(first + "<=" + second);
} else {
System.out.println(first + ">=" + second);
}
}
}
Comments
Post a Comment