Java Program to check Eligibility of TPP students for appearing in Interviews



Checking Eligibility of TPP Students in Java

Consider the following table for eligibility criteria of different companies for appearing in interviews:

CGPA

Eligible Company

Greater than or equal to 8

Google, Microsoft, Amazon, Dell, Intel, Wipro

Greater than or equal to 7

Tutorials point, accenture, Infosys, Emicon, Rellins

Greater than or equal to 6

rtCamp, Cybertech, Skybags, Killer, Raymond

Greater than or equal to 5

Patronics, Bata, Nobroker

Let's jump into the Java program to check the eligibility of TPP students for appearing in interviews using the following approach:

Using if-else-if Condition

There are multiple companies in the list, and to be eligible for those companies, there are multiple conditions or criteria. Since if-else-if statements are used when we have to check multiple conditions, we can use them to solve the given problem.

Example

In the following Java program, we are using the if-else-if statements to check the eligibility of TPP students for interviews.

public class Eligible {
   public static void main(String[] args) {
      int regd = 12109659;
      double CGPA = 8.08;
      if( CGPA >= 8 ) {
         System.out.println(regd + " is eligible for companies: Google, Microsoft, Amazon, Capgemini, Dell, Intel, Wipro");
      } else if(CGPA >= 7) {
         System.out.println(regd + " is eligible for companies: Tutorials point, accenture, Infosys, Emicon, Rellins");
      } else if(CGPA >= 6) {
         System.out.println(regd + " is eligible for companies: rtCamp, Cybertech, Skybags, Killer, Raymond");
      } else if( CGPA >= 5 ) {
         System.out.println(regd + " is eligible for companies: Patronics, Bata, Nobroker");
      } else {
         System.out.println("Improve yourself!");
      }
   }
}

Output:

12109659 is eligible for companies: Google, Microsoft, Amazon, Capgemini, Dell, Intel, Wiproe

Using Switch Statements

The switch statement works with int, short, byte, and char datatype only. It doesn't support decimal values. It first evaluates the expression, and if any of the cases match, then it will execute that block of code. If none of the cases match, then, default case gets executed.

The given problem needs to be evaluated on multiple cases. So, we can use a switch statement in our Java program.

Syntax

// expression and value must be of same datatype
switch(expression) {
   case value: 
   // code will be executed only when the expression and case value matched
   break;
   case value:
   // code will be executed only when the expression and case value matched
   break; 
   .
   .
   .
   case value n: // n is required number of value
   default: 
   //  If none of the case matched then it will be executed
}

Example

The following Java program shows how to check the eligibility of TPP students using switch statements.

public class Main {
   public static void main(String[] args){
      int regd = 12109659;
      double CGPA = 6.55;
      int GPA = (int) CGPA; 
      // typecasting double to integer type
      switch(GPA){ 
         // here GPA = 6
         case 10:
         case 9:
         case 8:
            System.out.println(regd + " is eligible for companies: Google, Microsoft, Amazon, Capgemini, Dell, Intel, Wipro");
            break;
         case 7:
            System.out.println(regd + " is eligible for companies: Tutorials point, accenture, Infosys, Emicon, Rellins");
            break;
         case 6:
            System.out.println(regd + " is eligible for companies: rtCamp, Cybertech, Skybags, Killer, Raymond");
            break;
         case 5:
            System.out.println(regd + " is eligible for companies: Patronics, Bata, Nobroker");
            break;
         default:
            System.out.println("Improve yourself!");
      }
   } 
}

Output

12109659 is eligible for companies: rtCamp, Cybertech, Skybags, Killer, Raymond

Example: User-defined Method

Let's see a Java program that demonstrates how to check the eligibility of TPP students with the help of a user-defined method.

public class Main {
   public static void eligible(int regd, double CGPA){
      if(CGPA >= 8){
         System.out.println(regd + " is eligible for companies: Google, Microsoft, Amazon, Capgemini, Dell, Intel, Wipro");
      } else if(CGPA >= 7){
         System.out.println(regd + " is eligible for companies: Tutorials point, accenture, Infosys, Emicon, Rellins");
      } else if(CGPA >= 6){
         System.out.println(regd + " is eligible for companies: rtCamp, Cybertech, Skybags, Killer, Raymond");
      } else if(CGPA >= 5){
         System.out.println(regd + " is eligible for companies: Patronics, Bata, Nobroker");
      } else {
         System.out.println("Improve yourself!");
      }
   }
   public static void main(String[] args){
      eligible(12109659, 7.89);
   }
}

Output:

12109659 is eligible for companies: Tutorials point, accenture, Infosys, Emicon, Rellins
Updated on: 2025-06-06T13:58:45+05:30

300 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements