$25
Objectives:
Implement a Object Oriented Program using Visual Studio. NET platform .
Exercise 1:
In Exercise 1 we will implement an Employee class that can be used to store details of an Employee working in a company
(a) In Visual C++, create a new Win32 Console Application project. Save the project in your
Desktop. We will name the project as Lab-05
If you are using a different IDE these steps are different, there is no need to use a wizard. Create the files as shown in Page 4 (the header files Employee.h, Employee.cpp and Lab05.cpp)
b) Add a new Class to the project from the main menu select, Project -> Add Class
Select the C++ Class Template.
(b) We will create a Class called Employee. When you specify the Class Name the Wizard creates the header file and the .cpp file.
Click the “Finish” button at the bottom of the “C++ Class Wizard”
Then you can see the Employee.h and the Employee.cpp files in the “Solution Explorer”
c) Write the definition of the Employee class in Employee.h header file. (Double click Employee.h from the Solution Explorer).
d) Implement Student class in Employee.cpp (Double click on Employee.cpp from the Solution Explorer.
e) Double click the “Lab-05.cpp” in the Solution explorer and implement the main program.
Main Program in Lab-05.cpp (f) Compile and Run the above program.
Exercise 2:
Add another method called “setOtDetails()” to assign the otHrs and otRate to the object. You need to add two more attributes called otHrs and otRate to the class. Calculate the new salary by adding the OT amount and display the details
Exercise 3:
Change the main program to input the details from the keyboard and send them to the relevant methods to assign details to the attributes.
You can also change the existing methods such as “assignDetails()”, “setAllowance()” and “setOtDetails()” to input values from the keyboard.
Eg :
void Employee::InputDetails()
{ cout<<”Input Employee No : “; cin >>empno; cout<<"Input Name : "; cin>>name;
cout<<"Input Basic Salary :"; cin>>basicSalary; }