-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2 i.java
More file actions
46 lines (43 loc) · 1.25 KB
/
task2 i.java
File metadata and controls
46 lines (43 loc) · 1.25 KB
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
36
37
38
39
40
41
42
43
44
45
46
//a program that dispalys largest number and smallest number
package java_methods;
//importing scanner
import java.util.Scanner;
public class Methods_in_java {
//declaring variables
static int num1,num2,num3;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//ask user to enter num1
System.out.println("enter num1");
num1 =input.nextInt();
//ask user to enter num2
System.out.println("enter num2");
num2 =input.nextInt();
//ask user to enter num3
System.out.println("enter num3");
num3 =input.nextInt();
if (num1>num2){
System.out.print(num1+"is largest");
}
else
if(num1>num3){
System.out.print(num1+"is largest");
}
else
if(num2 > num1){
System.out.print(num2+"is largest");
}
else
if(num2>num3){
System.out.print(num3+"is largest");
}
else
if(num3>num1){
System.out.print(num3+"is largest");
}
else
if(num3>num2){
System.out.print(num3+"is largest");
}
}
}