-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAgeIfElse.java
37 lines (35 loc) · 1.15 KB
/
AgeIfElse.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
36
37
import java.util.Scanner;
//wajp to determine oldest and youngest of 3 by age
class AgeIfElse {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Age of three people:");
int user1=sc.nextInt();
int user2=sc.nextInt();
int user3=sc.nextInt();
if((user1>=user2) && (user1>= user3)){
System.out.println("User1 is oldest");
if(user2<=user3){
System.out.println("User2 is Younger");
}else{
System.out.println("User3 is Younger");
}
}
else if((user2>user1) && (user2> user3)){
System.out.println("User2 is oldest");
if(user1<=user3){
System.out.println("User1 is Younger");
}else{
System.out.println("User3 is Younger");
}
}
else{
System.out.println("User3 is oldest");
if(user1<=user2){
System.out.println("User1 is Younger");
}else{
System.out.println("User2 is Younger");
}
}
}
}