Ads

Pages

Thursday, January 6, 2011

CS201 Assignment No. 3 solution

#include

#include
#include

class calsalary
{
private:
int empID,empGrade;
char empName[20];
int salary;
public:
calsalary()
{
empID=0;
empGrade=0;
strcpy(empName," ");
salary=0;
}
void getData()
{
cout<<"please enter employee ID:";
cin>>empID;
cout<<"Please enter employee Name:";
cin>>empName;
cout<<"Please enter employee Grade:";
cin>>empGrade;
}
int calculate(int grade)
{
switch(grade)
{
case 17:
salary=15000+(15000*45/100);
break;
case 18:
salary=20000+(20000*45/100);
break;
case 19:
salary=25000+(25000*45/100);
break;
default:
cout<< "Your typed Grade in not listed";
break;
}
return salary;
}
void setData()
{
cout<<"The net salary of" <
}

~calSalary()
{
}
};
int main(void)
{
calSalary obj1;
obj1.getData();
obj1.setData();

system("pause");
return 0;
}

.....................
#include
#include
#include
using namespace std;
class CalSalary
{private:
int EID, EGrade;
string Name;
public:
CalSalary()
{EID=0;
EGrade=0;
Name='/0';}
void GetInput()
{cout<<"please enter employee name : ";
cin>>Name;
cout<<"please enter employee ID : ";
cin>>EID;
cout<<"please enter employee Grade : ";
cin>>EGrade;}

int GetID()
{return EID;}
void SetID(int ID)
{EID=ID;}
int GetGrade()
{return EGrade;}
void SetGrade(int Grade)
{EID=Grade;}
string GetName()
{return Name;}
void SetName(string N)
{Name=N;}
void Calculate(int G)
{switch(G)

{case 17:
{cout<
break;}
case 18:
{cout<
break;}
case 19:
{cout<
break;}
default :
cout<<"Grade of Employee is incorrect"<

}
}

};
main()
{ int G=0;
CalSalary cal;
cal.GetInput();
G=cal.GetGrade();
cal.Calculate(G);
getch();
}

.............
#include
#include
#include
using namespace std;
class CalSalary
{private:
int EID, EGrade;
string Name;
public:
CalSalary()
{EID=0;
EGrade=0;
Name='/0';}
void GetInput()
{cout<<"please enter employee name : ";
cin>>Name;
cout<<"please enter employee ID : ";
cin>>EID;
cout<<"please enter employee Grade : ";
cin>>EGrade;}

int GetID()
{return EID;}
void SetID(int ID)
{EID=ID;}
int GetGrade()
{return EGrade;}
void SetGrade(int Grade)
{EID=Grade;}
string GetName()
{return Name;}
void SetName(string N)
{Name=N;}
void Calculate(int G)
{switch(G)

{case 17:
{cout<
break;}
case 18:
{cout<
break;}
case 19:
{cout<
break;}
default :
cout<<"Grade of Employee is incorrect"<

}
}

};
main()
{ int G=0;
CalSalary cal;
cal.GetInput();
G=cal.GetGrade();
cal.Calculate(G);
getch();
}

No comments:

Post a Comment