Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- class empolyee
- {
- char name[50];
- int ID;
- float basic, salary;
- public:
- void getdata()
- {
- cout<<"Enter ID"<<endl;
- cin>>ID;
- cout<<"Enter name"<<endl;
- cin>>name;
- cout<<"Enter basic";
- cin>>basic;
- }
- void calc(int bonus=0)
- {
- float hra = basic*0.15;
- float da=basic*0.15;
- salary= basic+ hra+ da+ bonus;
- }
- void display()
- {
- cout<<"\n"<<ID<<"\t"<<name<<"\t"<<basic<<"\t"<<salary;
- }
- }a[50];
- int main()
- {
- int n;
- cout<<"\nenter no of employees";
- cin>>n;
- //empolyee a[50];
- for(int i=0;i<n;i++)
- {
- a[i].getdata();
- if(i<5)
- a[i].calc(700);
- else if(i>=n-5&&i>4)
- a[i].calc(250);
- else
- a[i].calc();
- }
- cout<<"\n the employee details are\n";
- cout<<"\nID\tName\tBasic\tsalary";
- for( i=0;i<n;i++)
- {
- a[i].display();
- }
- return 0;
- }
- enter no of employees12
- Enter ID
- 1
- Enter name
- fdb
- Enter basic500
- Enter ID
- 2
- Enter name
- gfd
- Enter basic456
- Enter ID
- 56
- Enter name
- yfhhtr
- Enter basic848
- Enter ID
- 5
- Enter name
- hthtr
- Enter basic545
- Enter ID
- 7
- Enter name
- yr
- Enter basic546
- Enter ID
- 45
- Enter name
- yjryt
- Enter basic787
- Enter ID
- 5
- Enter name
- yjryjr
- Enter basic564
- Enter ID
- 25
- Enter name
- yfhytr
- Enter basic877
- Enter ID
- 55
- Enter name
- yjrd
- Enter basic666
- Enter ID
- 25
- Enter name
- htrhthtr
- Enter basic555
- Enter ID
- 5
- Enter name
- yjfyjr
- Enter basic785
- Enter ID
- 45
- Enter name
- fcfetr
- Enter basic321
- the employee details are
- ID Name Basic salary
- 1 fdb 500 1350
- 2 gfd 456 1292.8
- 56 yfhhtr 848 1802.4
- 5 hthtr 545 1408.5
- 7 yr 546 1409.8
- 45 yjryt 787 1023.1
- 5 yjryjr 564 733.2
- 25 yfhytr 877 1390.1
- 55 yjrd 666 1115.8
- 25 htrhthtr 555 971.5
- 5 yjfyjr 785 1270.5
- 45 fcfetr 321 667.3Press any key to continue
Advertisement
Add Comment
Please, Sign In to add comment