Page 185 - CA_Blue( J )_Class9
P. 185
You will get the following output:
Program 7 Write a program to check eligibility to vote.
1 import java.util.*;
2 public class conditional_statement
3 {
4 public static void main(String args[])
5 {
6 Scanner scan = new Scanner (System.in);
7 System.out.print("What is your age? \nAns: ");
8 int age = scan.nextInt ();
9 if (age >= 18)
10 System.out.println ("You can vote.");
11 else
12 System.out.println("You cannot vote.");
13 }
14 }
You will get the following output:
Conditional Constructs in Java 183

