Advertising
- shadeslayer
- Thursday, February 25th, 2010 at 12:39:10pm UTC
- #include<iostream.h>
- #include<conio.h>
- #include<stdio.h>
- class emp
- {
- private : float basic[5],gross[5],total[5];
- public : void getsal();
- void dispsal();
- void calsal();
- void sort();
- };
- void emp::getsal()
- {
- clrscr();
- for(int i=0;i<5;i++)
- {
- cout<<"Enter the basic salary of "<<i<<" person : ";
- cin>>basic[i];
- }
- }
- void emp::dispsal()
- {
- for(int j=0;j<5;j++)
- {
- cout<<"The salary of "<<j<<" employee is : "<<total[j]<<endl;
- }
- }
- void emp::calsal()
- {
- for(int i=0;i<5;i++)
- {
- if(basic[i]<=4000)
- {
- gross[i]=0.0;
- }
- else if(basic[i]>4000.0 && basic[i]<=10000)
- { gross[i]=0;
- gross[i]=0.1*basic[i];
- total[i]=gross[i]+basic[i];
- }
- else
- {
- gross[i]=0;
- gross[i]=0.2*basic[i];
- total[i]=gross[i]+basic[i];
- }
- }
- }
- void emp::sort()
- {
- float temp=0;
- for(int p=0;p<5;p++)
- {
- for(int q=0;q<5-p;q++)
- {
- if(total[q]>total[q+1])
- {
- temp=total[q];
- total[q]=total[q+1];
- total[q+1]=temp;
- }
- }
- }
- cout<<endl;
- }
- void main()
- {
- emp a;
- a.getsal();
- a.calsal();
- a.dispsal();
- cout<<endl<<"sorting"<<endl;
- a.sort();
- a.dispsal();
- getch();
- }
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.