Computer Science, asked by riddhima5033, 10 months ago

Write a program that accepts age and if age is equal to above 18 , displays message “you are eligible to vote” otherwise displays “Sorry your are not eligible to vote”

Answers

Answered by Wildbookaholic
0

Answer:

You are eligible to vote

Answered by bairagi787
2

Answer:

// Example for Nested If in Java Programming

package ConditionalStatements;

import java.util.Scanner;

public class NestedIf {

private static Scanner sc;

public static void main(String[] args) {

 int age;

 sc = new Scanner(System.in);  

 System.out.println(" Please Enter you Age: ");

 age = sc.nextInt();

 

 if (age < 18) {

  System.out.println("You are Minor.");

  System.out.println("You are Not Eligible to Work");

 }

 else  {

  if (age >= 18 && age <= 60 )  {

   System.out.println("You are Eligible to Work");

   System.out.println("Please fill in your details and apply");

  }

  else  {

   System.out.println("You are too old to work as per the Government rules");

   System.out.println("Please Collect your pension!");

  }

 }

 System.out.println("\nThis Message is coming from Outside the IF ELSE STATEMENT");

}

}

OUTPUT 1: From the screenshot below, you can observe that We entered the age of 16. Here, the first If condition is TRUE. So, the statements inside the first if block will execute.

Explanation:

Similar questions