forked from shivaylamba/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindGreatestNumber.java
35 lines (34 loc) · 1011 Bytes
/
FindGreatestNumber.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
public class FindGreatestNumber {
int num1,num2,num3;
public void setvalue(){
Scanner sc = new Scanner(System.in);
System.out.print("Enter the first number:");
num1 = sc.nextInt();
System.out.print("Enter the second number:");
num2 = sc.nextInt();
System.out.print("Enter the third number:");
num3 = sc.nextInt();
sc.close();
}
public void calcGreatest(){
if(num1 > num2 && num1 > num3)
{
System.out.println("Greatest number is:"+num1);
}
else if(num2 > num3)
{
System.out.println("Greatest number is:"+num2);
}
else
{
System.out.println("Greatest number is:"+num3);
}
}
public static void main(String[] args) {
System.out.println("Program to Find Greatest Number");
FindGreatestNumber g = new FindGreatestNumber();
g.setvalue();
g.calcGreatest();
}
}