Jump to content
Sign in to follow this  
radit

Program Absensi

Recommended Posts

salam knal

nama saya adit saya dari jakarta

tolong bantu saya ya..

saya lagi mencoba belajar c++

tolong ya beri contoh program c++ absensi karyawan

terima kasih buat teman-teman semua

thx & regards

aditia mahendra

Share this post


Link to post
Share on other sites

adakah absensi karyawan itu sama dengan catatan rekod kedatangan pekerja..? tau rekod prestasi pekerja atau rekod bla..bla..bla..?

aku tak paham lagi ni... macamana nak tolong..

dan lagi satu... no offense.. heheheh.. kang jadi international political issue plak..

mungkinkah atau adakah setiap negara akan ada segelintir pelajar yang lebih suka disuapkan daripada mengangkat tangan sendiri dan menyuapkan ke dalam mulut sendiri... yaperdaaa aku cakap...

Share this post


Link to post
Share on other sites

Nak senang guna C++ Builder....

Sehari pun leh siap kalau dah ada DB...utk yg ringkas je la

Edited by zerocool

Share this post


Link to post
Share on other sites

code taken from PSC written by Bagus Adiyanto Dob

mungkin boleh membantu

/**************************************
//     
//INCLUDE files for :Employee Informatio
//     n Package
//**************************************
//     
struct Employee


    {
    	int id;
    	char firstname[30];
    	char address[50];
    	float hoursworked;
    	float wage;
};

class Data


    {
    	public:
      Data();
      void AddRecord();
      void DelRecord();
      void PrintPayStubs();
      void CreateFile();
    void ViewRecord();
    	private:
      void ReadFromFile(Employee[]);
      int SearchEmptyRecord(Employee[]);
      void WriteToFile(Employee[]);
      int Search(Employee[],int);
      float CountedGrossPay(float,float);
      float CountedTotalTax(float);
      float CountedNetPay(float,float);
      void ShowRecord(Employee[],int);
      Employee record[11];
      float FederalTaxRate;
      float StateTaxRate;
      float GrossPay;
      float TotalTaxAmount,NetPay;
};

Data::Data()//constructor


    {
    	for(int i=0;i<11;i++)


        	{
          record[i].id=0;
          strcpy(record[i].firstname," ");
          strcpy(record[i].address," ");
          record[i].hoursworked=0.0;
          record[i].wage=0.0;
        	}
        	FederalTaxRate=0.15; //this tax rate is only assumption
        	StateTaxRate=0.05;
    }

    void Data::CreateFile() //this class implementation is only used when the first


        {        	//time i run the program to create file
        	ofstream fout("A:\data.txt",ios::out);
        	for(int i=0;i<11;i++)


            	{
              fout<<record[i].id<<"\t";
              fout<<record[i].firstname<<"\t";
              fout<<record[i].address<<"\t";
              fout<<record[i].hoursworked<<"\t";
              fout<<record[i].wage<<"\n";
            	}
            	fout.close();
        }

        void Data::AddRecord() //to add record to the blank record


            {
            	int location;
            	char ans;
            	ReadFromFile(record);
            	do

                	{
                  clrscr();
                  location=SearchEmptyRecord(record); //to find empty record
                  if (location==-1)


                      {
                        cout<<"You have reached maximum capacity\n";
                      }
                      else

                          {
                          	gotoxy(14,10);cout<<"enter employee id : "<<(location+1)<<"\n";
                          	record[location].id=(location+1);//to assign customer id automatically
                          	cin.ignore();
                          	gotoxy(14,11);cout<<"enter employee first name : ";
                          	cin.get(record[location].firstname,30);
                          	cin.ignore();
                          	gotoxy(14,12);cout<<"enter employee address: ";
                          	cin.get(record[location].address,40);
                          	gotoxy(14,13);cout<<"enter employee hours : ";
                          	cin>>record[location].hoursworked;
                          	gotoxy(14,14);cout<<"enter employee wage: ";
                          	cin>>record[location].wage;
                          	WriteToFile(record);
                          }
                          gotoxy(14,15);cout<<"do you want to add record again : ";
                          cin>>ans;
                        	}while(ans=='y'||ans=='Y');
                    }

                    void Data::ReadFromFile(Employee a[])//to read the data from the file and assign them to


                        {//variable
                        	ifstream fin("A:\data.txt",ios::in);
                        	for(int i=0;(!fin.eof()&&i<11);i++)


                            	{
                              fin>>a[i].id;
                              fin.ignore();
                              fin.getline(a[i].firstname,(strlen(a[i].firstname)+1));
                              fin.ignore();
                              fin.getline(a[i].address,(strlen(a[i].address)+1));
                              fin>>a[i].hoursworked;
                              fin>>a[i].wage;
                            	}
                            	fin.close();
                        }

                        int Data::SearchEmptyRecord(Employee a[])


                            {
                            	int i=0;
                            	while(i<11)


                                	{
                                  if(a[i].id==0)//if customer id equal to zero it means the record is empty
                                  	return i;
                                  else
                                  	i++;
                                	}
                                	return -1;
                            }

                            void Data::WriteToFile(Employee a[])//to write the data hold in variable to the file


                                {
                                	ofstream fout;
                                	fout.open("A:\data.txt",ios::out);
                                	for(int i=0;i<11;i++)


                                    	{
                                      fout<<a[i].id<<"\t";
                                      fout<<a[i].firstname<<"\t";
                                      fout<<a[i].address<<"\t";
                                      fout<<a[i].hoursworked<<"\t";
                                      fout<<a[i].wage<<"\n";
                                    	}
                                    	fout.close();
                                }

                                void Data::ViewRecord()//to view certain record with using customer id as primary key


                                    {
                                    	int key,location;
                                    	ReadFromFile(record);
                                    	gotoxy(14,9);cout<<"Enter employee # id number that you want to see : ";
                                    	cin>>key;
                                    	location=Search(record,key);
                                    	if (location==-1)


                                        	{
                                          gotoxy(14,10);cout<<"Record not found\n";
                                        	}
                                        	else
                                          ShowRecord(record,location);
                                    }

                                    int Data::Search(Employee a[],int target)//to find certain record in array with using linear search


                                        {
                                        	int i=0;
                                        	while(i<11)


                                            	{
                                              if (a[i].id==target)
                                              	return i;
                                              else
                                              	i++;
                                            	}
                                            	return -1;
                                        }

                                        void Data::DelRecord()


                                            {
                                            	char ans;
                                            	int key,location;
                                            	ReadFromFile(record);
                                            	gotoxy(14,9);cout<<"Enter employee # id that you want to delete : ";
                                            	cin>>key;
                                            	location=Search(record,key);
                                            	if (location==-1)


                                                	{
                                                   gotoxy(14,10);cout<<"Record not found";
                                                	}
                                                	else

                                                    	{
                                                      ShowRecord(record,location);
                                                      gotoxy(14,15);cout<<"Are you sure you want to delete this record(y/n) : ";
                                                      cin>>ans;
                                                      if (ans=='y'||ans=='Y')


                                                          {
                                                          	record[location].id=0;
                                                          	strcpy(record[location].firstname," ");
                                                          	strcpy(record[location].address," ");
                                                          	record[location].hoursworked=0.0;
                                                          	record[location].wage=0.0;
                                                          	WriteToFile(record);
                                                          }
                                                        	}
                                                    }

                                                    void Data::PrintPayStubs()


                                                        {
                                                        	int key,location;
                                                        	ReadFromFile(record);
                                                        	gotoxy(14,9);cout<<"Enter employee # id number: ";
                                                        	cin>>key;
                                                        	location=Search(record,key);
                                                        	if (location==-1)
                                                          cout<<"Record not found";
                                                        	else

                                                            	{
                                                              GrossPay=CountedGrossPay(record[location].wage,record[location].hoursworked);
                                                              TotalTaxAmount=CountedTotalTax(GrossPay);
                                                              NetPay=CountedNetPay(GrossPay,TotalTaxAmount);
                                                              gotoxy(14,10);	cout<<"****************WEEKLY PAY STUBS*******************\n";
                                                              gotoxy(14,11);	cout<<"Employee name\t\t: "<<record[location].firstname<<endl;
                                                              gotoxy(14,12); cout<<"Employee address\t: "<<record[location].address<<endl;
                                                              gotoxy(14,13); cout<<"Gross Pay\t\t: "<<"$ "<<GrossPay<<endl;
                                                              gotoxy(14,14); cout<<"Tax Withheld\t\t: "<<"$ "<<TotalTaxAmount<<endl;
                                                              gotoxy(14,15); cout<<"NetPay\t\t\t: "<<"$ "<<NetPay<<endl;
                                                              gotoxy(14,16); cout<<"Employee wage\t\t: "<<"$ "<<record[location].wage<<endl;
                                                              gotoxy(14,17); cout<<"***************************************************\n";
                                                            	}
                                                        }

                                                        float Data::CountedGrossPay(float Wage,float Hours)


                                                            {
                                                            	if (Hours>40)


                                                                	{
                                                                  return((40*Wage)+((Hours-40)*Wage*1.5));
                                                                	}
                                                                	else
                                                                  return(40*Wage);
                                                            }

                                                            float Data::CountedTotalTax(float GrossPay)


                                                                {
                                                                	return(GrossPay*(FederalTaxRate+StateTaxRate));
                                                            }

                                                            float Data::CountedNetPay(float GrossPay,float TaxAmount)


                                                                {
                                                                	return(GrossPay-TaxAmount);
                                                            }

                                                            void Data::ShowRecord(Employee a[],int location)


                                                                {
                                                                	gotoxy(14,10);cout<<"Employee id : "<<a[location].id<<endl;
                                                                	gotoxy(14,11);cout<<"Employee name: "<<a[location].firstname<<endl;
                                                                	gotoxy(14,12);cout<<"Employee address : "<<a[location].address<<endl;
                                                                	gotoxy(14,13);cout<<"Employee hours: "<<a[location].hoursworked<<endl;
                                                                	gotoxy(14,14);cout<<"Employee wage: "<<a[location].wage<<endl;
                                                            }

JANGAN MALAS

Edited by BudakCumpung

Share this post


Link to post
Share on other sites

code taken from PSC written by Bagus Adiyanto Dob

I think you (radit) might search the code on PSC ... 'BudakCumpung' already giving a hint ...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...