Please some one urgent help me in this code

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 13
Reputation: shahid is an unknown quantity at this point 
Solved Threads: 0
shahid shahid is offline Offline
Newbie Poster

Please some one urgent help me in this code

 
0
  #1
Jun 26th, 2005
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:

  1. //Header Files
  2. #include<iostream.h>
  3. #include<conio.h>
  4.  
  5. //class definition
  6. class Employee{
  7. //hidden part of the class Employee
  8. private:
  9.  
  10. int id;
  11.  
  12. char name;
  13.  
  14. int sal;
  15.  
  16. char address;
  17.  
  18. public:
  19.  
  20. void setid(int);
  21. void setname(char);
  22. void setsal(int);
  23. void setaddress(char);
  24.  
  25. int getid();
  26. char getname();
  27. int getsal();
  28. char getaddress();
  29. //to input data
  30. void input();
  31. //to display data values
  32. void display();
  33.  
  34. void checkmanger();
  35.  
  36. int numberCheck(char temp[]);
  37.  
  38. Employee();
  39.  
  40. ~Employee();
  41.  
  42. };
  43.  
  44.  
  45. Employee::Employee()
  46. {
  47. id=0;
  48. name=0;
  49. sal=0;
  50. address=0;
  51. cout<<"\n \t \t constructor called"<<endl;
  52. cout<<"\t \t ===================== \n"<<endl;
  53. }
  54.  
  55.  
  56. Employee::~Employee()
  57. {
  58. cout<<"\t \t The object has been destroyed"<<endl;
  59. cout<<"\t \t ============================ \n"<<endl;
  60. getch();
  61. }
  62.  
  63.  
  64.  
  65. void Employee::display()
  66.  
  67. {
  68. //input();
  69.  
  70. cout<<"\t===================================================="<<"\n"<<endl;
  71. cout<<"\t Employee id: "<<getid()<<"\n"<<endl;
  72. cout<<"\t Employee name: "<<getname()<<"\n"<<endl;
  73. cout<<"\t Employee salary: "<<getsal()<<"\n"<<endl;
  74. cout<<"\t Employee address: "<<getaddress()<<"\n"<<endl;
  75.  
  76. }
  77.  
  78.  
  79.  
  80. void Employee::input()
  81.  
  82. {
  83. //input();
  84.  
  85.  
  86. setid(201);
  87. setname('N');
  88. setsal(10000);
  89. setaddress('a');
  90.  
  91. }
  92.  
  93.  
  94. void Employee::setid(int)
  95. {
  96. id=0;
  97. }
  98.  
  99.  
  100. int Employee::getid()
  101. {
  102. return id;
  103. }
  104.  
  105. void Employee::setname(char)
  106. {
  107. name=0;
  108. }
  109.  
  110. char Employee::getname()
  111. {
  112. return name;
  113. }
  114.  
  115. void Employee::setsal(int)
  116. {
  117. sal=0;
  118. }
  119.  
  120. int Employee::getsal()
  121. {
  122. return sal;
  123. }
  124.  
  125. void Employee::setaddress(char)
  126. {
  127. address=0;
  128. }
  129.  
  130.  
  131. char Employee::getaddress()
  132. {
  133. return address;
  134. }
  135.  
  136. void Employee::checkmanger()
  137. {
  138. //int salary;
  139. if(sal<=0)
  140.  
  141. cout<<"\t The employee is programmer"<<"\n"<<endl;
  142.  
  143. else
  144. cout<<"\t The Employee managerer: "<<sal<<"\n"<<endl;
  145.  
  146. }
  147.  
  148. //main function
  149. void main()
  150. {
  151. // declaring object of the class Employee
  152. Employee Emp;
  153. //calling function input
  154. Emp.input();
  155. //calling function display
  156. Emp.display();
  157. //calling function checkmanger
  158. Emp.checkmanger();
  159. }
<< 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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC