-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerGrouping.java
More file actions
46 lines (46 loc) · 1.23 KB
/
Copy pathCustomerGrouping.java
File metadata and controls
46 lines (46 loc) · 1.23 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
/*
Q9. Customer Grouping (Medium)
Customers are grouped according to age and gender.
Group 1: Males under 25 years old
Group 2: Females under 25 years old
Group 3: Males between 25 - 45 years old
Group 4: Females between 25 - 45 years old
Group 5: All people over 45 years old.
Note : Gender code for a male is 1 and for female is 2. Display Invalid if user enters other gender
codes.
Input format :
Age in first line
Gender code in second line
Output format :
Group number
Sample test cases :
Input :
23
1
Output :
Group 1
*/
package week1;
import java.util.Scanner;
public class CustomerGrouping {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int age = sc.nextInt(), genderCode = sc.nextInt();
if((age>0) && (genderCode==1 || genderCode==2)) {
if(age < 25 && genderCode == 1) {
System.out.println("Group 1");
}
if((age>=25 && age <=45) && genderCode ==1 ){
System.out.println("Group 3");
}
if(age < 25 && genderCode == 2) {
System.out.println("Group 2");
}
if((age>=25 && age <=45) && genderCode ==2 ){
System.out.println("Group 4");
}
if(age>45) System.out.println("Group 5");
} else System.out.println("Invalid entry");
sc.close();
}
}