From 5db918e106649132a3800017e19a65a0bb468ad3 Mon Sep 17 00:00:00 2001 From: avinchudasama100 <72938199+avinchudasama100@users.noreply.github.com> Date: Sun, 25 Oct 2020 00:27:06 +0530 Subject: [PATCH] greatestnumber program to find the greatest two number in java --- greatestnumber | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 greatestnumber diff --git a/greatestnumber b/greatestnumber new file mode 100644 index 0000000..cdda6e6 --- /dev/null +++ b/greatestnumber @@ -0,0 +1,24 @@ +import java.util.Scanner; +public class greatest_of_two_numbers +{ + public static void main(String[] args) + { + //scanner class declaration + Scanner sc = new Scanner(System.in); + //input first number + System.out.print("Enter the first number : "); + int first = sc.nextInt(); + //input second number + System.out.print("Enter the second number : "); + 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(); + } +}