Java program to find which department has highest placement program

A simple Java program to find which department has highest placement program. VSB College wishes to honour the department that has received the most number of placements for the current academic year. The departments that took part in the recruitment campaign were three in all. Assist the college in locating the department with the most placements.

import java.util.Scanner;
public class Main
{
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter no of students placed in Computer science");
int Computerscience= sc.nextInt();
System.out.println("Enter no of students placed in Electronics");
int Electronics=sc.nextInt();
System.out.println("Enter no of students placed in Mechanical");
int Mechanical=sc.nextInt();

if(Computerscience<0||Electronics<0||Mechanical<0)
{
System.out.println("Enter the number properly");
}
else if(Computerscience==Electronics && Electronics==Mechanical)
{
System.out.println("None of the department has got the highest placement");
}

else if(Computerscience==Electronics && Mechanical<Computerscience)
{
System.out.println("Highest placement");
System.out.println("Computer science");
System.out.println("Electronics");
}

else if(Computerscience==Mechanical && Electronics<Mechanical)
{
System.out.println("Highest placement");
System.out.println("Computer science");
System.out.println("Mechanical");
}

else if(Electronics==Mechanical && Computerscience<Mechanical)
{
System.out.println("Highest placement");
System.out.println("Electronics");
System.out.println("Mechanical");
}

else if(Computerscience>Electronics&&Computerscience>Mechanical)
{
System.out.println("Highest placement");
System.out.println("Computer science");
}

else if(Electronics>Computerscience && Electronics>Mechanical)
{
System.out.println("Highest placement");
System.out.println("Electronics");
}

else if(Mechanical>Computerscience && Mechanical>Electronics)
{
System.out.println("Highest placement");
System.out.println("Mechanical");
}
}
}

 

Output:

Enter no of students placed in Computer science
400
Enter no of students placed in Electronics
200
Enter no of students placed in Mechanical
100
Highest placement
Computer science

Difference between if else and if else ladder in java

When the if the condition is false, it instructs the code what to do. The if-else-if ladder statement combines numerous statements into one condition. If the statement in the if block evaluates to true, it will be executed. The last else block is assessed if none of the if conditions evaluate to true.

You can create a chain of if statements using the if/else if statement. The if statements are evaluated one after the other until one of the if expressions is true or the if/else if chain ends. If there is no true expression at the end of the if/else if chain, no code blocks are executed.

The if block will be run if the Boolean statement evaluates to true; else, the else block will be executed. Any non-zero and non-null values are assumed to be true in the C programming language, while zero and null values are assumed to be false.

What is nested if else program in java

An if statement that is the target of another if or otherwise is known as a nested if. An if statement inside an if statement is referred to as nested if statements. Yes, we may stack if statements within if statements in Java.

The final else line will be executed if none of the conditions are true. An if-else statement with another if statement as the if body or the else body is known as a nested if statement. Here’s an illustration: Evaluate the outer if condition if the outer if condition evaluates to true. Run the if body (the println() statement) if it evaluates to true.

Disadvantages of nested if else program in java

The nested ifs are difficult to comprehend and change. The readability of the program reduces as the depth of nesting grows. When a sequence of decisions must be made one after the other, each decision or condition may include expressions that result in an integer number.

What is if else ladder program in java and how to implement in program

The if-else-if ladder is a typical programming construct that is built on nested ifs. This is how it seems. From the top-down, conditional expressions are evaluated. The statement associated with a true condition is executed as soon as it is found, and the rest of the ladder is skipped.

What is campus placement program in college

Campus placement, often known as campus recruiting, is a program that provides jobs to students nearing the end of their studies at universities or other educational institutions. Companies who want to recruit from the student population cooperate with educational institutions in this type of initiative.