#include<iostream.h>
#include<string.h>
class Staff{
protected:
char id[10];
char name[20];
long salary;
public:
void input();
void output();
long getSalary();
long setSalary();
};
void Staff::input()
{cout<<"Id: ";cin.seekg(0,ios::end);cin.get(id,10);
cout<<"Name: ";cin>>name;
cout<<"Salary: ";cin>>salary;
}
void Staff::output()
{cout<<id<<"\t"<<name<<"\t"<<salary<<"\t"<<endl;
}
long Staff::setSalary()
{return salary;
}
long Staff::getSalary()
{return salary;}
void deleteSalary(Staff s[],int n)
{int sa;
cout<<"Delte salary: ";cin>>sa;
for(int i=0;i<n;i++)
if(s[i].getSalary()==sa)
{ n=n-1;
for(int j=i;j<n;j++)
s[j]=s[j+1];
i--;
}
cout<<"Id\tName\tSalary"<<endl;
for(i=0;i<n;i++)
{s[i].output();
}
}
void sortSalary(Staff s[],int n)
{
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
if(s[i].getSalary()>s[j].getSalary())
{Staff tmp=s[i];
s[i]=s[j];
s[j]=tmp;
}
cout<<"Id\tName\tSalary"<<endl;
for(i=0;i<n;i++)
{s[i].output();
}
}
void updateSalary(Staff s[],int n)
{int sa1;
cout<<"Update Salary: ";cin>>sa1;
for(int i=0;i<n;i++)
if(s[i].getSalary()==sa1)
{
cout<<"New Salary: ";cin>>s[i].setSalary();
}
for(i=0;i<n;i++)
{s[i].output();
}
}
void main()
{ Staff st[50];
int n,sw;
cout<<"Number of Staff: ";cin>>n;
for(int i=0;i<n;i++)
{st[i].input();
}
cout<<"Press '1' for Sorting Salary."<<endl;
cout<<"Press '2' for Deleting salary."<<endl;
cout<<"Press '3' for Update salary."<<endl;
loop:
cout<<"Please choose one of them: ";cin>>sw;
switch(sw)
{ case 1: sortSalary(st,n);
break;
case 2: deleteSalary(st,n);
break;
case 3: updateSalary(st,n);
break;
default: cout<<"Please choose again."<<endl;
goto loop;
break;
}
}
#include<string.h>
class Staff{
protected:
char id[10];
char name[20];
long salary;
public:
void input();
void output();
long getSalary();
long setSalary();
};
void Staff::input()
{cout<<"Id: ";cin.seekg(0,ios::end);cin.get(id,10);
cout<<"Name: ";cin>>name;
cout<<"Salary: ";cin>>salary;
}
void Staff::output()
{cout<<id<<"\t"<<name<<"\t"<<salary<<"\t"<<endl;
}
long Staff::setSalary()
{return salary;
}
long Staff::getSalary()
{return salary;}
void deleteSalary(Staff s[],int n)
{int sa;
cout<<"Delte salary: ";cin>>sa;
for(int i=0;i<n;i++)
if(s[i].getSalary()==sa)
{ n=n-1;
for(int j=i;j<n;j++)
s[j]=s[j+1];
i--;
}
cout<<"Id\tName\tSalary"<<endl;
for(i=0;i<n;i++)
{s[i].output();
}
}
void sortSalary(Staff s[],int n)
{
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
if(s[i].getSalary()>s[j].getSalary())
{Staff tmp=s[i];
s[i]=s[j];
s[j]=tmp;
}
cout<<"Id\tName\tSalary"<<endl;
for(i=0;i<n;i++)
{s[i].output();
}
}
void updateSalary(Staff s[],int n)
{int sa1;
cout<<"Update Salary: ";cin>>sa1;
for(int i=0;i<n;i++)
if(s[i].getSalary()==sa1)
{
cout<<"New Salary: ";cin>>s[i].setSalary();
}
for(i=0;i<n;i++)
{s[i].output();
}
}
void main()
{ Staff st[50];
int n,sw;
cout<<"Number of Staff: ";cin>>n;
for(int i=0;i<n;i++)
{st[i].input();
}
cout<<"Press '1' for Sorting Salary."<<endl;
cout<<"Press '2' for Deleting salary."<<endl;
cout<<"Press '3' for Update salary."<<endl;
loop:
cout<<"Please choose one of them: ";cin>>sw;
switch(sw)
{ case 1: sortSalary(st,n);
break;
case 2: deleteSalary(st,n);
break;
case 3: updateSalary(st,n);
break;
default: cout<<"Please choose again."<<endl;
goto loop;
break;
}
}
You truly did more than visitors’ expectations. Thank you for rendering these helpful, trusted, edifying and also cool thoughts on the topic to Kate.Rprogramming Training in pune
ReplyDeleteRprogramming Training in
Bangalore
Rprogramming Training in btm
Rprogramming Training in bangalore
Rprogramming Training in tambaram
Rprogramming Training in annanagar
This comment has been removed by the author.
ReplyDelete