Repository navigation
Expand file tree
/
Copy pathQ24.java
More file actions
59 lines (55 loc) · 2.19 KB
/
Copy pathQ24.java
File metadata and controls
59 lines (55 loc) · 2.19 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
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.Scanner;
/*
Write a Java program for Company Insurance Policy. A company insure its driver under the following conditions
If driver is married
If driver is unmarried male and age above 30
If driver is unmarried female and age above 25
*/
public class Q24 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter M if you are married, U if you are unmarried: ");
char ch = sc.next().charAt(0);
switch (ch)
{
case 'M' , 'm'://Married
System.out.println("You ARE ELIGIBLE for driver insurance");
break;
case 'U' , 'u'://Unmarried
System.out.println("Enter M if you are Male, F if you are Female");
char chr = sc.next().charAt(0);
System.out.println("Enter your age: ");
int age = sc.nextInt();
switch(chr)
{
case 'M' , 'm'://Male
if (age >= 30)
{
System.out.println("Congratulations! You ARE ELIGIBLE for driver insurance");
}
else
{
System.out.println("Sorry, you are NOT ELIGIBLE for driver insurance");
}
break;
case 'F' , 'f'://Female
if (age >= 25)
{
System.out.println("Congratulations! You ARE ELIGIBLE for driver insurance");
}
else
{
System.out.println("Sorry, you are NOT ELIGIBLE for driver insurance");
}
break;
default:
System.out.println("Invalid choice");
break;
}
break;
default:
System.out.println("Invalid choice");
break;
}
}
}