Write a Java program to allow the user to input his/her age. Then the program will show if the person is eligible to vote. A person who is eligible to vote must be older than or equal to 18 years old.
INPUT
15
OUTPUT
You are not eligible to vote
import java.io.*; import java.util.*; public class temp { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the Age: "); int age = scan.nextInt(); if(age>=18){ System.out.print("You are eligible to vote");} else{ System.out.print("You are not eligible to vote");} } }
INPUT_1:
Enter the Age: 18
OUTPUT:
You are eligible to vote
INPUT_2:
Enter the Age: 17
OUTPUT:
You are not eligible to vote
INPUT_3:
Enter the Age: 50
OUTPUT:
You are eligible to vote
INPUT_4:
Enter the Age: 12
OUTPUT:
You are not eligible to vote
INPUT_5:
Enter the Age: 33
OUTPUT:
You are eligible to vote
ILLUSTRATION
![](http://www.fcukthecode.com/wp-content/uploads/2022/03/Screenshot-from-2022-03-27-17-33-30.png)
Morae Q!
- Convert from binary number to decimal number.
- Swap two numbers by using division and multiplication.
- Compute foot and inches into centimetres.
- Concatenate Strings.
- Convert lowercase letters to uppercase letters.
- Compute the sum of all the digits of N.
- Compute the area of the pentagon.
- Get input using scanner.
- Find the distance between two points (x1,y1) and (x2,y2).
- Finding patterns in a file using frep and egrep .
- Detecting a cycle in a directed graph using Depth First Traversal.
- Topological ordering in a Graph.
- Storing graphs using adjacency list.
- Introduction to graph theory.
- Graph Adjacency Matrix pseudo code.
- Adjacency Matrix for storing graphs.
- Dijkstra’s shortest path algorithm .
- Breadth first search (BFS) Algorithm.
- Find the multiple of given number in the list of integers.
- Finding patterns in files using grep .