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 [Link];
public class EmployeePerformance {
public static void main(String[] args) {
Scanner sc=new Scanner([Link]);
[Link]("Scores of Work Quality: ");
int a=[Link]();
[Link]("Scores of Punctuality: ");
int b=[Link]();
[Link]("Scores of Teamwork: ");
int c=[Link]();
[Link]("Scores of Problem-Solving: ");
int d=[Link]();
[Link]("Scores of Communication: ");
int e=[Link]();
int per=(a+b+c+d+e)*100/500;
[Link]("Percentage of Employees: "+per);
if(per>=90) {
[Link]("Outstanding");
}
else if (per>=80 && per<90) {
[Link]("Excellent");
}
else if (per>=70 && per<80) {
[Link]("Good");
}
else if (per>=60 && per<70) {
[Link]("Average");
}
else if (per>=50 && per<60) {
[Link]("Below Average");
}
else if (per<50) {
[Link]("Unsatisfactory");
}
}
}
OUTPUT:
QUESTION 2: Write a Java program to generate the factorial of a
given number.
import [Link].*;
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([Link]);
[Link]("Enter a number: ");
int a = [Link]();
FactorialCalculator Fact = new FactorialCalculator();
[Link]([Link](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() {
[Link]="Unknown";
[Link]="Unassigned";
[Link]=0.0;
}
public Employee() {
[Link]("No argument constructor called");
}
public Employee(String name, String position, double salary) {
[Link]=name;
[Link]=position;
[Link]=salary;
}
public void displayEmployeeDetails() {
[Link]("Name: "+name);
[Link]("Position: "+position);
[Link]("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);
[Link]("Employee 1: ");
[Link]();
[Link]("Employee 2: ");
[Link]();
[Link]("Employee 3: ");
[Link]();
}
}
OUTPUT: