Bite-Code™

Home » Post Item » Payroll System

Payroll System

March 1, 2010

//Use CodeBlocks Studio version 1.0.
#include <iostream>
#include <string>
using namespace std;

class person{       //class:person

    string first;
    string last;
    char middle;
    int age;
    string gender;
    string position;
    int salary;

    public:void setfirst(string myfirst){
        first=myfirst;
    }
    public:void setmiddle(char mymiddle){
        middle=mymiddle;
    }
    public:void setlast(string mylast){
        last=mylast;
    }
    public:void setage(int myage){
        age=myage;
    }
    public:void setgender(string mygender){
        gender=mygender;
    }
     public:void setposition(string myposition){
        position=myposition;
    }
    public:void setsalary(int mysalary){
        salary=mysalary;
    }


    public:string getfirst(){
    return first;
    }
    public:char getmiddle(){
    return middle;
    }
    public:string getlast(){
    return last;
    }
     public:int getage(){
    return age;
    }
    public:string getgender(){
    return gender;
    }
    public:string getposition(){
    return position;
    }
    public:int getsalary(){
    return salary;
    }
};

    int main()
{
                              //object:you

    string fname;
    char mname;
    string lname;
    int age;
    string gender;
    string position;
    int salary;
    char con;
    person you[5];

    cout<<endl;
    cout<<”\t\t\t\17 Simple Payroll System \17 \n”;
    cout<<endl;
    for(int i=0; i<5; i++)
    {
    cout<<”Enter first name [”<<i<<”] :”;
    cin>>fname;
    cout<<”Enter middle initial: “;
    cin>>mname;
    cout<<”Enter last name: “;
    cin>>lname;
    cout<<”Enter age: “;
    cin>>  age;
    cout<<”Enter gender: “;
    cin>>gender;
    cout<<”Enter position: “;
    cin>> position;
    cout<<”Enter Annual salary: “;
    cin>> salary;
    salary = salary*12;
    cout<<”\n”;

    you[i].setfirst(fname);
    you[i].setmiddle(mname);
    you[i].setlast(lname);
    you[i].setage(age);
    you[i].setgender(gender);
    you[i].setposition(position);
    you[i].setsalary(salary);

    }
    system(”cls”);
    cout<<endl;
    cout << “\n\t\t\t Do you want to continue?[Y/N] : “;
         cin >> con;
         if ((con == ‘y’)|| (con == ‘Y’))
         {
            cout<<endl;
             }

    for(int i=0; i<5; i++)
    {
    cout<<”Name “<<i<<” :”<<you[i].getlast()<<”, “<<you[i].getfirst()<<” “<<you[i].getmiddle()<<”.”<<endl;
    cout<<”Age: “<<you[i].getage()<<endl;
    cout<<”Gender: “<<you[i].getgender()<<endl;
    cout<<”Position: “<<you[i].getposition()<<endl;
    cout<<”Annual salary: “<<you[i].getsalary()<<endl;
    cout<<”\n”;
    cout<<”\n”;
    }
    return 0;
}


 

Posted by mowllen at 10:22 am | permalink

All comments are moderated. Your comments will not appear here unless approved by the blog owner. Thank you.

Add a comment