Page 313 - CA_Blue( J )_Class10
P. 313
4 String ename,dept;
5 double basic,hra,da, tot_sal;
6 salary()
7 {
8 ename=""; dept="";
9 basic=0.0; hra=0.0; da=0.0; tot_sal=0.0;
10 }
11 void input()
12 {
13 Scanner sc= new Scanner(System.in);
14 System.out.println("Enter name,department and basic salary : ");
15 ename=sc.next();
16 dept=sc.next();
17 basic=sc.nextDouble();
18 }
19 void calculate()
20 {
21 hra = 0.15 * basic;
22 da = 0.5 * basic;
23 }
24 void total_sal()
25 {
26 tot_sal = basic + hra+ da;
27 }
28 void display()
29 {
30 System.out.println("Name"+"\t"+"Dept"+"\t"+"Basic"+"\t"+"HRA"+"\
t"+"DA"+"\t"+"Total Salary ");
31 System.out.println(ename+"\t"+dept+"\t"+basic+"\t"+hra+"\t"+da+"\t"+tot_sal);
32 }
33 public static void main()
34 {
35 salary ob = new salary();
36 ob.input();
37 ob.calculate();
311
Constructors 311

