Pages

Write a program in C++ to get employee name and its salary and print employee name, salary and grand salary(total salary+10% of salary) [Updated]

Monday 22 April 2013


#include <iostream.h>
class employee
{
     char firstName[50];
     char lastName[50];
     int salary;
     public:
            employee()
            {
                strcpy(firstName, "NULL");
                strcpy(lastName, "NULL");
                salary=0;    
            }
            void setfn()
            {
                 cout<<"Enter First Name of Emplyee: ";
                 cin>>firstName;
            }
            void setln()
            {
                 char ln;
                 cout<<"Enter Last Name of Emplyee: ";
                 cin>>lastName;
            }
            void sets()
            {
                 int s;
                 cout<<"Enter salary of "<<firstName<<" "<<lastName<<": ";
                 cin>>s;
                 if(s<0){s=0;}
                 salary=s;
            }
            void dfn()
            {
                 cout<<"First Name is: "<<firstName<<endl;
            }
            void dln()
            {
                 cout<<"Last Name is: "<<lastName<<endl;
            }
            void dsalary()
            {
                 cout<<"Salary of "<<firstName<<" "<<lastName<<" of one year is: "<<salary*12<<endl;
                 cout<<"Salary with 10% of "<<firstName<<" "<<lastName<<" is: "<<((salary*10)/100)+salary<<endl;
            }
};
int main()
{
    char a;
    employee e1;
    again:
    e1.setfn();
    e1.setln();
    e1.sets();
    e1.dfn();
    e1.dln();
    e1.dsalary();
    cout<<"Would you like to put data of new employee: ";
    cin>>a;
    if(a=='y' || a=='Y'){goto again;}
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *