Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
* * * * * 1 votes

Very Simple Payroll System In Java (Dos Base)

simple payroll system how to make payroll system payroll system DOS BASE PAYROLL payroll in java making payroll in java

  • Please log in to reply
25 replies to this topic

#13 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 01 October 2012 - 06:36 AM

im only helping my girlfriend for her project. :) im not good at this :(

been looking for many sites for this Payroll thing


ohh she must try to do it with herself first, he won't get any knowledge or learn if you help him so much and give him a full source code project.. You can make it as base but
don't copy codes without understanding them :)
  • 0
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#14 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts
  • Programming Language:C#, PHP
  • Learning:Assembly

Posted 01 October 2012 - 08:54 AM

Very good tutorial +1 ... thanks for zip.
  • 0

www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#15 AlamBrohi

AlamBrohi

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 21 November 2012 - 09:58 PM

This program doesn't work

import java.io.*;
public class payroll {
   public static void main(String args[])throws IOException{
  
boolean notExists = true;

while(notExists == true) {
//objects
FileInputStream fstream = new FileInputStream("Employee.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader textReader = new BufferedReader(new InputStreamReader(in));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

//Declarations
String str = "", UserInput = "", tmp = "";
String empcode = "", empname = "", emplevel = "";
double emprate = 0;
int ctr = 0;
String timeIn = "", timeOut = "", holiday = "", overtin = "", overtout = "";
double totalHours = 0, hours = 0, minutes = 0, tmpTime = 0, late = 0, undertime = 0, overHours = 0, overMinutes = 0;
double salary = 0, overSal = 0, tmpSal = 0, regular = 0;
double tmpLate = 0, tmpHour = 0, tmpUndertime = 0;



System.out.print("Enter Employee Code : ");
UserInput = br.readLine();

//loop through the text file
while( (str = textReader.readLine()) != null ) {
if ( str.equalsIgnoreCase(UserInput) ) {
  empcode = UserInput;
								   //found the userinput, store the details now
  while( (tmp = textReader.readLine()) != null) {
   //lets put everyline into a variable for reference use
switch(ctr) {
case 0:
empname = tmp;
break;
case 1:
emplevel = tmp;
break;
case 2:
emprate = Double.parseDouble(tmp);
break;
}
ctr++;

  }

}
//System.out.println(str);
}

System.out.println();
System.out.println();

//check if record exists
if( !(empcode.equalsIgnoreCase("")) ) {
//display the record if it exists
System.out.println("-------------------Employee Details---------------------------");
System.out.println("Name of the Employee : " + empname);
System.out.println("Employee Code : " + empcode);
System.out.println("Employee Level : " +emplevel);
System.out.println("Employee Rate : " + emprate);

//enter for time in and time out
String CurrentDay = "";
int ctr2 = 1;
while(ctr2 <= 5){
switch(ctr2) {
case 1:
CurrentDay = "Monday";
break;
case 2:
CurrentDay = "Tuesday";
break;
case 3:
CurrentDay = "Wednesday";
break;
case 4:
CurrentDay = "Thursday";
break;
case 5:
CurrentDay = "Friday";
break;
}
System.out.println();
System.out.println();

//ask for time in and time out for regular and overtime
//also ask if today is holiday
System.out.print("Enter Time In for " + CurrentDay + " : ");
timeIn = br.readLine();
System.out.print("Enter Time Out for " + CurrentDay + " : ");
timeOut = br.readLine();
System.out.print("Is today holiday? [y/n] : ");
holiday = br.readLine();
System.out.print("Enter Time In for Over Time : ");
overtin = br.readLine();
System.out.print("Enter Time Out for Over Time : ");
overtout = br.readLine();

//split the hour and minute
String tin[] = timeIn.split(":");
String tout[] = timeOut.split(":");


//time calculation
hours += ( Double.parseDouble(tout[0]) - Double.parseDouble(tin[0]) ) >= 9 ? 8 : Double.parseDouble(tout[0]) - Double.parseDouble(tin[0]);
tmpTime = Double.parseDouble(tout[0]) - Double.parseDouble(tin[0]);
tmpHour = ( Double.parseDouble(tout[0]) - Double.parseDouble(tin[0]) ) >= 9 ? 8 : Double.parseDouble(tout[0]) - Double.parseDouble(tin[0]);

//minute late and under time calculation
if ( tmpTime <= 9 ) {
late += Double.parseDouble(tin[1]);
tmpLate = Double.parseDouble(tin[1]);
}

if ( Double.parseDouble(tout[0]) < 17 ) {
undertime += 60 - Double.parseDouble(tout[1]);
tmpUndertime = 60 - Double.parseDouble(tout[1]);
}


//salary rate calculation
if ( holiday.equalsIgnoreCase("y") ) {
tmpSal = (emprate / 8) * 1.1;
tmpTime = (( (tmpHour*60) - (tmpLate + tmpUndertime) ) / 60);
hours -= tmpTime;
overHours += (( (tmpHour*60) - (tmpLate + tmpUndertime) ) / 60);
overSal += tmpSal * tmpTime;
} else {
tmpSal = emprate / 8;
tmpTime = (( (tmpHour*60) - (tmpLate + tmpUndertime) ) / 60);
salary += tmpSal * tmpTime;
//System.out.println(salary + " = " + tmpSal * tmpHour + " " + tmpLate + " " + tmpUndertime + " ");
}

//if there is overtime
if ( !( overtin.equalsIgnoreCase("00:00") || overtin.equalsIgnoreCase("") ) ) {
String ovin[] = overtin.split(":");
String ovout[] = overtout.split(":");

double tmp1 = 0;
double tmp2 = 0;
double minTmp = 0;

tmp1 = Double.parseDouble(ovin[0]) <= 17 ? 17 : Double.parseDouble(ovin[0]);
tmp2 = Double.parseDouble(ovout[0]) <= 20 ? 20 : 20;
minTmp = Double.parseDouble(ovin[1]) + Double.parseDouble(ovout[1]);

if ( (tmp2 - tmp1) <= 3 && tmp2 - tmp1 > 0) {
overMinutes = ((tmp2 - tmp1) * 60) - minTmp;
overHours += overMinutes/60;
double overTmp = overMinutes/60;
double overRate = (emprate / 8) * 1.1;
overSal += overRate * overTmp;
}
}

ctr2++;
}

System.out.print("Enter Date Covered : " );
String covered = br.readLine();
minutes += (hours*60) - (late + undertime);
totalHours = minutes/60;

System.out.println();

System.out.println();
System.out.println("-------------------------------------------");
System.out.println("Name of the Employee : " + empname);
System.out.println("Employee Code : " + empcode);
System.out.println("Employee Level : " +emplevel);
System.out.println("Employee Rate : " + emprate);
System.out.println("-------------------------------------------");
System.out.println("Date Covered : " + covered);
System.out.println("Total Hours : " + totalHours);
System.out.println("Overtime : " + overHours);
System.out.println("Regular Income : " + salary );
System.out.println("Overtime Income : " + overSal );
System.out.println("Gross Income : " + (salary + overSal) );
System.out.println("Deductions");

//tax and gsis deduction computation
double tax = ((salary + overSal) * .10);
double gsis = 0;

if( emplevel.equalsIgnoreCase("Level 1") ) {
gsis = (salary + overSal) * .01;
} else if ( emplevel.equalsIgnoreCase("Level 2") ) {
gsis = (salary + overSal) * .015;
} else {
gsis = (salary + overSal) * 0.02;
}

System.out.println("	* Tax : " + tax);
System.out.println("	* GSIS : " + gsis);
System.out.println("Net Income : " + (( (salary + overSal) - (tax + gsis) ) + 500) );

System.out.println("-------------------------------------------");

notExists = false;

} else {
System.out.println("-------------------Record Doesn't Exists---------------------------");
notExists = true;
}


		  }

   }

}

Edited by Roger, 22 November 2012 - 09:31 AM.
remove format (left justify) and added code tags

  • 0

#16 Chall

Chall

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 349 posts
  • Location:Cedar Rapids, IA
  • Programming Language:Java
  • Learning:C, Java, C++, C#, Python, JavaScript, Assembly

Posted 21 November 2012 - 10:41 PM

You should put all that code in code blocks (Go into editor, highlight the code, and press the '<>' button).
  • 0
Speaks fluent Java

#17 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 22 November 2012 - 06:07 AM

please specify the errors :D

Edited by Roger, 22 November 2012 - 09:32 AM.
removed quoted content

  • 0
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#18 Roger

Roger

    Skadoosh!

  • Administrator
  • 1222 posts
  • Programming Language:C, PHP
  • Learning:Others

Posted 22 November 2012 - 09:37 AM

This program doesn't work


Posting your errors would allow people to help you with the problem.

You should put all that code in code blocks (Go into editor, highlight the code, and press the '<>' button).


Even better would be to remove the "centered" code using "Remove Format" (eraser head) and then the Posted Image! :)
  • 0

New around here? Click here to register and start participating in under a minute?

Or do a quick search and you may find the answer you're looking for.


#19 codinggeek

codinggeek

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts
  • Learning:Java, C++, C#, PHP, (Visual) Basic, PL/SQL

Posted 05 January 2013 - 02:36 AM

we are having a case study, almost the same with this one. i hope you can help me with mine.
  • 0

#20 Sarah007

Sarah007

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts
  • Location:Philippines, Manila
  • Programming Language:Java, (Visual) Basic
  • Learning:Java, C++, PHP, (Visual) Basic, Visual Basic .NET

Posted 25 April 2013 - 05:58 PM

Thanks papabear it helps me alot, i dont care to other comments about your post, for me you are the best. I study your code and now i understand it. thank you and god bless.

 

And to all other people. "This Code is Working!"

I tried it in java netbeans and notepad.


Edited by Sarah007, 25 April 2013 - 06:00 PM.

  • 0

#21 bernalzmba

bernalzmba

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 04 February 2014 - 03:52 PM

good day sir!!

 

i tried to run your program, and its really working, but i have a few question sir,  why is that the overtime displays 2.5 for inputs 17:30 18:00??

 

while(ctr2 <= 5)  -----> I tried to change this in while(ctr2<=1) so i can check if the overtime is correct.
              

  {
                    switch(ctr2) {
                    case 1:
                        CurrentDay = "Monday";
                        break;
                    case 2:
                        CurrentDay = "Tuesday";
                        break;
                    case 3:
                        CurrentDay = "Wednesday";
                        break;
                    case 4:
                        CurrentDay = "Thursday";
                        break;
                    case 5:
                        CurrentDay = "Friday";
                        break;
                    }
                    /*Time In and Time Out of the Employee*/
                    timeIn = JOptionPane.showInputDialog("Enter Time In for " + CurrentDay + " : ");
                    timeOut = JOptionPane.showInputDialog("Enter Time Out for " + CurrentDay + " :

Edited by Roger, 25 February 2014 - 12:55 PM.
added codetags

  • 0

#22 lalachan

lalachan

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 24 February 2014 - 10:10 PM

Hello! :biggrin: Your codes are very helpful! Thank you so much! :) its the same like my prof gave to us, payroll system is our project for finals and we don't know how to do this because he never teach this payroll system :3 Because of you my finals project in java is done!  :biggrin: but i wonder, how can I change the employee name and its employee codes? Thank you again god-bless to you!  :) 

 

- phil

:thumbup: 


  • 0

#23 germax

germax

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 25 February 2014 - 02:43 AM

Sir how about a codes that will record the time-in and time-out of the employee entered into the systerm?


  • 0

#24 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 25 February 2014 - 01:03 PM

Welcome aobard Bernalzmba, Germax, and lalachan.

 

I suggest you make your introduction post and later maybe share the code you have been working with.

 

We are happy to have you here.

 

Happy coding.


  • 0





Also tagged with one or more of these keywords: simple payroll system, how to make payroll system, payroll system, DOS BASE PAYROLL, payroll in java, making payroll in java