create a program to find the greater number out of two numbers entered by the
user.
Answers
Explanation:
//Java program to find greatest of two numbers
Import java.util
Public static void main
class greatest_of_two_numbers{ public static void main(String[] args) {
Scanner sc = new Scanner(System.in)
System.out.print("Enter the first number : ");
System.out.print("Enter the first number : "); int first = sc.nextInt();
System.out.print("Enter the first number : "); int first = sc.nextInt(); System.out.print("Enter the second number :") ;
int second = sc.nextInt();
int second = sc.nextInt(); //conditions
int second = sc.nextInt(); //conditions if(first > second)
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second);
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second); else if(second > first)
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second); else if(second > first) System.out.println(second+" is greater than "+first);
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second); else if(second > first) System.out.println(second+" is greater than "+first); else
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second); else if(second > first) System.out.println(second+" is greater than "+first); else System.out.println("Both numbers are Equal");
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second); else if(second > first) System.out.println(second+" is greater than "+first); else System.out.println("Both numbers are Equal"); //closing scanner class(not compulsory, but good practice)
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second); else if(second > first) System.out.println(second+" is greater than "+first); else System.out.println("Both numbers are Equal"); //closing scanner class(not compulsory, but good practice) sc.close();
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second); else if(second > first) System.out.println(second+" is greater than "+first); else System.out.println("Both numbers are Equal"); //closing scanner class(not compulsory, but good practice) sc.close(); }
int second = sc.nextInt(); //conditions if(first > second) System.out.println(first+" is greater than "+second); else if(second > first) System.out.println(second+" is greater than "+first); else System.out.println("Both numbers are Equal"); //closing scanner class(not compulsory, but good practice) sc.close(); }}