Java program used to check if TPP students are eligible for interviews
Please consider the table below to know the eligibility criteria of different companies -
CGPA | is: Grade Point Average |
Eligible companies |
---|---|---|
is greater than or equal to 8 |
Google, Microsoft, Amazon, Dell, Intel, Wipro |
|
is greater than or equal to 7 |
Tutorial point, accent, Infosys, Emicon, Rellins |
|
is greater than or equal to 6 |
rtCamp、Cybertech、Skybags、Killer、Raymond |
|
is greater than or equal to 5 |
Patronics, Shoes, NoBrokers |
Let us enter the java program to check the eligibility of tpp students for interview.
Method 1: Use if else if condition
Usually, when we have to check multiple conditions, we use if else if statement. It follows a top-down approach.
grammar
if(condition 1) { // code will be executed only when condition 1 is true } else if(condition 2) { // code will be executed only when condition 2 is true } else { // code will be executed when all of the above condition is false }
Example
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
In the above code, we declare and initialize two variables named "regd" and "CGPA". When we run this code, the compiler will check the first if condition and for the given "CGPA" value, it is true. Therefore, it executes the code inside the first if block.
How to use Switch statement
The switch statement is only available for int, short, byte and char data types. It does not support decimal values. It first evaluates the expression and if any of the conditions match, it executes the block of code. If no cases match, the default case is executed.
grammar
// 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
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
In the above code, we have used the same variable again. Since switch is not compatible with double variables, we typecast it to an integer type variable named "GPA". Case 6 matches the expression for the given value of "GPA". Therefore, the compiler executes the case 6 code.
Method 3: Use user-defined method
Methods are blocks of code that can be reused multiple times to perform a single operation. It saves us time and also reduces code size.
grammar
accessSpecifier nonAccessModifier return_Type method_Name(Parameters){ //Body of the method }
accessSpecifier - used to set the accessibility of a method. It can be public, protected, default, and private.
nonAccessModifier - It shows additional functionality or behavior of a method such as static and final.
return_Type − The data type that the method will return. We use void keyword when the method does not return anything.
method_Name - The name of the method.
Parameters - It contains the variable name followed by the data type.
Example
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
The logic of the above program is the same as the first program we discussed in this article. The main difference is that we created a user-defined method called "eligible()" with two parameters "regd" and "CGPA" and we called that method with two parameters in the main method.
in conclusion
In this article, we have discussed three java program methods for checking whether a tpp student is eligible for interview. We saw the use of if else if condition and switch statement. We also created a user-defined method for a given problem.
The above is the detailed content of Java program used to check if TPP students are eligible for interviews. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The program being executed is called a process. A process can be an application running on the current operating system or an application related to the operating system. If an application is tied to the operating system, it first creates a process to execute itself. Other applications rely on operating system services for execution. Most applications are operating system services and background applications that maintain the operating system, software, and hardware. In python we have different methods to check if application is open or not. Let’s learn about them in detail one by one. Using the psutil.process_iter() function psutil is a module in Python that provides users with an interface to retrieve information about running processes and system utilization.

An iterable object is an object whose all elements can be iterated over using a loop or iterable function. Lists, strings, dictionaries, tuples, etc. are all called iterable objects. In Python language, there are various ways to check whether an object is iterable. Let’s take a look one by one. Using Loops In Python, we have two looping techniques, one is using "for" loop and the other is using "while" loop. Using either of these two loops, we can check if a given object is iterable. Example In this example, we will try to iterate an object using "for" loop and check if it is iterated or not. Below is the code. l=["apple",22,"orang
![Spellcheck not working in Teams [Fixed]](https://img.php.cn/upload/article/000/887/227/170968741326618.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
We've started noticing that sometimes spellcheck stops working for Teams. Spell check is an essential tool for effective communication, and any attack on it can cause considerable disruption to workflow. In this article, we'll explore common reasons why spell check might not be working as expected, and how to restore it to its previous state. So, if spell check is not working in Teams, follow the solutions mentioned in this article. Why doesn't Microsoft spell check work? There may be several reasons why Microsoft spell check is not working properly. These reasons include incompatible language settings, disabled spell check function, damaged MSTeam or MSOffice installation, etc. Also, outdated MSTeams and MSOf

How to check SSD health status in Windows 11? For their fast read, write, and access speeds, SSDs are quickly replacing HDDs, but even though they are more reliable, you still need to check the health of your SSDs in Windows 11. How to operate it? In this tutorial, the editor will share with you the method. Method 1: Use WMIC1, use the key combination Win+R, type wmic, and then press or click OK. Enter2. Now, type or paste the following command to check the SSD health status: diskdrivegetstatus If you receive the "Status: OK" message, your SSD drive is operating normally.

ThisarticleusesvariousapproachesforselectingthecommandsinsertedintheopenedcommandwindowthroughtheJavacode.Thecommandwindowisopenedbyusing‘cmd’.Here,themethodsofdoingthesamearespecifiedusingJavacode.TheCommandwindowisfirstopenedusingtheJavaprogram.Iti

How to check if a string starts with a specific character in Golang? When programming in Golang, you often encounter situations where you need to check whether a string begins with a specific character. To meet this requirement, we can use the functions provided by the strings package in Golang to achieve this. Next, we will introduce in detail how to use Golang to check whether a string starts with a specific character, with specific code examples. In Golang, we can use HasPrefix from the strings package

The Java language is one of the most commonly used object-oriented programming languages in the world today. The concept of classes is one of the most important features of object-oriented languages. A class is like a blueprint for an object. For example, when we want to build a house, we first create a blueprint of the house, in other words, we create a plan that shows how we are going to build the house. According to this plan we can build many houses. Likewise, using classes, we can create many objects. Classes are blueprints for creating many objects, where objects are real-world entities like cars, bikes, pens, etc. A class has the characteristics of all objects, and the objects have the values of these characteristics. In this article, we will write a Java program to find the perimeter and faces of a rectangle using the concept of classes

The size of a file is the amount of storage space that a specific file takes up on a specific storage device, such as a hard drive. The size of a file is measured in bytes. In this section, we will discuss how to implement a java program to get the size of a given file in bytes, kilobytes and megabytes. A byte is the smallest unit of digital information. One byte equals eight bits. One kilobyte (KB) = 1,024 bytes, one megabyte (MB) = 1,024KB, one gigabyte (GB) = 1,024MB and one terabyte (TB) = 1,024GB. The size of a file usually depends on the type of file and the amount of data it contains. Taking a text document as an example, the file size may be only a few kilobytes, while a high-resolution image or video file may be
