Else if

For more blogs related to Java click below-

👉 Java

1.

 import java.util.Scanner;

public class Test

 {

public static void main(String args[]) 

  {

int per;

Scanner s1 = new Scanner(System.in);  

System.out.println("Enter the age");

per = s1.nextInt();

if(per>=70)

     {

      System.out.println("Section 'A' ");  

     }

else if(per>=60 && per<70)

     {

     System.out.println("Section 'B' ");

     } 

else if(per>=50 && per<60) 

    {

     System.out.println("Section 'C' ");

    } 

  }

 } 

2. 

import java.util.Scanner;

public class Test

 {

public static void main(String args[]) 

  {

int age;

Scanner s1 = new Scanner(System.in);  

System.out.println("Enter the age");

age = s1.nextInt();

if(age>=70)

     {

      System.out.println("Eligible for Exam 'A' ");  

     }

else if(age>=60 && age<70)

     {

     System.out.println("Eligible for Exam 'B' ");

     } 

else if(age>=50 && age<60) 

    {

     System.out.println("Age Exceeded");

    } 

  }

 }  


Comments