0% found this document useful (0 votes)
10 views5 pages

Sessional 1

The document contains Java programs for evaluating employee performance based on scores, calculating the factorial of a number, and managing employee details using different types of constructors. The first program uses decision-making statements to classify performance levels, while the second program implements a recursive method for factorial calculation. The third program demonstrates the use of default, no-arg, and parameterized constructors to manage employee information.

Uploaded by

samay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Sessional 1

The document contains Java programs for evaluating employee performance based on scores, calculating the factorial of a number, and managing employee details using different types of constructors. The first program uses decision-making statements to classify performance levels, while the second program implements a recursive method for factorial calculation. The third program demonstrates the use of default, no-arg, and parameterized constructors to manage employee information.

Uploaded by

samay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Name: Arihant Kumar Shounak

Roll No.: 2301330120028


Branch: Computer Science
Section: B
Workshop Lab Number: 308 B

QUESTION 1: Write a Java program that uses decision-making


statements to determine and display the performance level of an
employee based on their evaluation scores.:

import java.util.Scanner;
public class EmployeePerformance {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Scores of Work Quality: ");
int a=sc.nextInt();
System.out.println("Scores of Punctuality: ");
int b=sc.nextInt();
System.out.println("Scores of Teamwork: ");
int c=sc.nextInt();
System.out.println("Scores of Problem-Solving: ");
int d=sc.nextInt();
System.out.println("Scores of Communication: ");
int e=sc.nextInt();
int per=(a+b+c+d+e)*100/500;

System.out.println("Percentage of Employees: "+per);


if(per>=90) {
System.out.println("Outstanding");
}
else if (per>=80 && per<90) {
System.out.println("Excellent");
}
else if (per>=70 && per<80) {
System.out.println("Good");
}
else if (per>=60 && per<70) {
System.out.println("Average");
}
else if (per>=50 && per<60) {
System.out.println("Below Average");
}
else if (per<50) {
System.out.println("Unsatisfactory");
}
}
}

OUTPUT:
QUESTION 2: Write a Java program to generate the factorial of a
given number.
import java.util.*;
public class FactorialCalculator {
public static int fac(int num) {
if (num == 0) {
return 1;
}else {
return num * fac(num -1);
}

}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int a = sc.nextInt();
FactorialCalculator Fact = new FactorialCalculator();
System.out.println(Fact.fac(a));

}
}

OUTPUT:
Question 4: Write a Java program to manage Employee details
using the concepts of default constructor, no-arg constructor
defined by the programmer, and parameterized constructor.
class Employee {
private String name;
private String position;
private double salary;

public void Employee() {


this.name="Unknown";
this.position="Unassigned";
this.salary=0.0;
}

public Employee() {
System.out.println("No argument constructor called");
}

public Employee(String name, String position, double salary) {


this.name=name;
this.position=position;
this.salary=salary;
}

public void displayEmployeeDetails() {


System.out.println("Name: "+name);
System.out.println("Position: "+position);
System.out.println("Salary: "+salary);
}
}
public class Main {
public static void main(String[] args) {
Employee emp1= new Employee();
Employee emp2= new Employee();
Employee emp3= new Employee("Aman", "Manager", 80000);

System.out.println("Employee 1: ");
emp1.displayEmployeeDetails();
System.out.println("Employee 2: ");
emp2.displayEmployeeDetails();
System.out.println("Employee 3: ");
emp3.displayEmployeeDetails();
}
}
OUTPUT:

You might also like