ICSE Java Programming Class employee 2023 Q3 SPECIMEN PAPER Solved.
import java.util.Scanner;
public class ICSEJava2023 {
public static void main(String[] args) {
employee obj = new employee();
obj.accept();
obj.calculate();
obj.print();
}
}
class employee {
public void print() {
System.out.println("Details of the employee:");
System.out.println("Employee number:" + eno);
System.out.println("Employee name:" + ename);
System.out.println("Age of the employee:" + age);
System.out.println("Basic pay of the employee:" + basic);
System.out.println("Net pay of the employee:" + net);
}
public void calculate() {
if (this.age > 50)
this.net = allowance + (basic + (hra * basic + da * basic - pf * basic) / 100f);
else
this.net = basic + (hra * basic + da * basic - pf * basic) / 100f;
}
public void accept() {
Scanner in = new Scanner(System.in);
System.out.print("Enter the employee number:");
eno = in.nextInt();
System.out.print("Enter the employee name:");
ename = in.nextLine();
in.nextLine();
System.out.print("Enter the age of the employee:");
age = in.nextInt();
System.out.print("Enter the basic pay of the employee:");
basic = in.nextFloat();
in.close();
}
employee() {
this.eno = 0;
this.ename = "";
this.age = 0;
this.basic = 0;
this.net = 0;
}
private int eno;
private String ename;
private int age;
private float basic;
private float net;
private static float hra = 18.5f;
private static float da = 17.45f;
private static float pf = 8.10f;
private static float allowance = 5000f;
}
No comments:
Post a Comment