-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEligibleVote.java
More file actions
46 lines (45 loc) · 1.02 KB
/
Copy pathEligibleVote.java
File metadata and controls
46 lines (45 loc) · 1.02 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
import java.util.*;
class EligibleVote
{
public static int vote(int age)
{
if(age>=18)
{
System.out.println("eligible");
}
else{
System.out.println("not_eligible");
}
return 0;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int age=sc.nextInt();
vote(age);
}
}
//this is other way--------------------------------------------------------------//
import java.util.*;
class EligibleVote
{
public static boolean vote(int age)
{
if(age>=18)
{
return true;
//System.out.println("eligible");
}
else{
return false;
//System.out.println("not_eligible");
}
//return 0;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int age=sc.nextInt();
System.out.println(vote(age));
}
}