Check Age for Voting
This program checks if a person is eligible to vote.
Problem Statement
Write a Java program that checks if age is 18 or above.
Source Code
| 1 | public class VotingAge { |
| 2 | public static void main(String[] args) { |
| 3 | int age = 17; |
| 4 | if(age >= 18) { |
| 5 | System.out.println("Eligible to vote - Eduinq"); |
| 6 | } else { |
| 7 | System.out.println("Not eligible to vote - Eduinq"); |
| 8 | } |
| 9 | } |
| 10 | } |
Program Output
Not eligible to vote - Eduinq
Explanation
The condition age >= 18 checks voting eligibility and prints the appropriate message based on the result. Demonstrates if-else for eligibility checks.