Page 288 - ComputerScience_Class_11
P. 288
Counter ob2 = new Counter();
ob1.display();
ob1.incre();
ob1.display();
ob2.incre();
ob2.display();
}
}
4. class Employee {
String name;
double basicsal, hra, da, pf, gross, net;
Employee(String en, double bsal) {
name = en;
basicsal = bsal;
}
void calculate() {
hra = 0.1 * basicsal;
da = 0.55 * basicsal;
pf = 0.0833 * basicsal;
gross = basicsal + hra + da;
net = gross - pf;
}
void display() {
System.out.println("Name: " + name);
System.out.println("Basic Salary: " + basicsal);
System.out.println("HRA: " + hra);
System.out.println("DA: " + da);
System.out.println("PF: " + pf);
System.out.println("Gross Salary: " + gross);
System.out.println("Net Salary: " + net);
}
public static void main(String[] args) {
Employee e1 = new Employee("Ajay”, 40000);
e1.calculate();
e1.display();
}
}
H. Unsolved Programs:
1. Define a class guard having the following specifications:
Data Members
String gn : Name of the guard
int hr : Hours worked
double rate : Stores rate per hour
double wg : Stores wage received by the guard
Member Methods
gurad(String n, int h) : Constructor to assign n to gn and h to hr
void calwage() : Calculates the wage of the guard as per the table given below
286 Touchpad Computer Science (Ver. 3.0)-XI

