| | |
Please some one urgent help me in this code
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2005
Posts: 13
Reputation:
Solved Threads: 0
My program does take the inputs from user and does not given required results and also does not check the employee is a manger or programmer. Please some one check my code and correct it or write a better coding for this program. Code and program details is given below.Thanks.
Code:
<< moderator edit: added code tags: [code][/code] >>
I write a C++ program which stores the information about of the company’s employees.
Create a class named as Employee having following attributes.
1: id
2: name
3: sal
4: address
Take input of all the four attributes from the user using four different setter functions.
Your class has following member functions.
1: display ()
2: checkmanger()
Member function display() will display all the records of employee using four different getter functions. Call all the four getter functions in this member function to display the records of employee.
Make a member function checkmanager() that will find out whether the employee is manager or not if he has salary greater than or equal to 15,000 then he will be considered as a manager and if his salary is less than 15,000 then he will be considered as programmer.
Where employee salary cannot be less than zero.
Write setters and getters for all the four data members to set and get values. Write also constructor for the class.
Also write destructor for the class Firm.
Sample Output
1)
Enter Employee id: 201
Enter Employee name: Akram
Enter Employee salary: 20000
Enter Employee address: Lahore
Employee id: 201
Employee name: Akram
Employee salary: 20000
Employee address: Lahore
The employee is manger.
2)
Enter Employee id: 402
Enter Employee name: Ali
Enter Employee salary: 10000
Enter Employee address: Lahore
Employee id: 402
Employee name: Ali
Employee salary: 10000
Employee address: Lahore
The employee is Programmer.
Code:
C++ Syntax (Toggle Plain Text)
//Header Files #include<iostream.h> #include<conio.h> //class definition class Employee{ //hidden part of the class Employee private: int id; char name; int sal; char address; public: void setid(int); void setname(char); void setsal(int); void setaddress(char); int getid(); char getname(); int getsal(); char getaddress(); //to input data void input(); //to display data values void display(); void checkmanger(); int numberCheck(char temp[]); Employee(); ~Employee(); }; Employee::Employee() { id=0; name=0; sal=0; address=0; cout<<"\n \t \t constructor called"<<endl; cout<<"\t \t ===================== \n"<<endl; } Employee::~Employee() { cout<<"\t \t The object has been destroyed"<<endl; cout<<"\t \t ============================ \n"<<endl; getch(); } void Employee::display() { //input(); cout<<"\t===================================================="<<"\n"<<endl; cout<<"\t Employee id: "<<getid()<<"\n"<<endl; cout<<"\t Employee name: "<<getname()<<"\n"<<endl; cout<<"\t Employee salary: "<<getsal()<<"\n"<<endl; cout<<"\t Employee address: "<<getaddress()<<"\n"<<endl; } void Employee::input() { //input(); setid(201); setname('N'); setsal(10000); setaddress('a'); } void Employee::setid(int) { id=0; } int Employee::getid() { return id; } void Employee::setname(char) { name=0; } char Employee::getname() { return name; } void Employee::setsal(int) { sal=0; } int Employee::getsal() { return sal; } void Employee::setaddress(char) { address=0; } char Employee::getaddress() { return address; } void Employee::checkmanger() { //int salary; if(sal<=0) cout<<"\t The employee is programmer"<<"\n"<<endl; else cout<<"\t The Employee managerer: "<<sal<<"\n"<<endl; } //main function void main() { // declaring object of the class Employee Employee Emp; //calling function input Emp.input(); //calling function display Emp.display(); //calling function checkmanger Emp.checkmanger(); }
I write a C++ program which stores the information about of the company’s employees.
Create a class named as Employee having following attributes.
1: id
2: name
3: sal
4: address
Take input of all the four attributes from the user using four different setter functions.
Your class has following member functions.
1: display ()
2: checkmanger()
Member function display() will display all the records of employee using four different getter functions. Call all the four getter functions in this member function to display the records of employee.
Make a member function checkmanager() that will find out whether the employee is manager or not if he has salary greater than or equal to 15,000 then he will be considered as a manager and if his salary is less than 15,000 then he will be considered as programmer.
Where employee salary cannot be less than zero.
Write setters and getters for all the four data members to set and get values. Write also constructor for the class.
Also write destructor for the class Firm.
Sample Output
1)
Enter Employee id: 201
Enter Employee name: Akram
Enter Employee salary: 20000
Enter Employee address: Lahore
Employee id: 201
Employee name: Akram
Employee salary: 20000
Employee address: Lahore
The employee is manger.
2)
Enter Employee id: 402
Enter Employee name: Ali
Enter Employee salary: 10000
Enter Employee address: Lahore
Employee id: 402
Employee name: Ali
Employee salary: 10000
Employee address: Lahore
The employee is Programmer.
![]() |
Similar Threads
- Using Shell Script how to send mail automatically (Shell Scripting)
- xml parsing from java (Java)
- Urgent...Having problem with the following HTML code in IE7 (HTML and CSS)
- Excel to ASP database (ASP)
- opening files in classes (C++)
Other Threads in the C++ Forum
- Previous Thread: C++ linked list help??
- Next Thread: Output 2D array?
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





