Results 1 to 8 of 8

Thread: Payroll program

  1. #1
    bigley04 is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

    Exclamation Payroll program

    How would I design and write a payroll program? The program first has to ask for the first name, last name, hours worked, and hourly wage; reading the users response into memory. It then computes gross pay (hours worked X hourly wage), tax (10% for gross pay), and net pay (gross pay - tax). Finally it prints a pay check for the net pay and a pay stub detailing the calculations.

    also how would you modify the program to input first name, last name, hours worked, and hourly wage from a file for set of employees (at least ten). Then be able to print a pay check and pay stub for each.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You would go through the homework assignment instructions one step at a time, and try to solve each small step in isolation before tackling the next one. If you run into further trouble, please show us your code attempt.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    You would go through the homework assignment instructions one step at a time, and try to solve each small step in isolation before tackling the next one. If you run into further trouble, please show us your code attempt.
    Yes, we are not doing assignments. As Fubarable pointed above, we can help to improve your skills only.

  4. #4
    bigley04 is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

    Default I got it

    Java Code:
    import java.util.Scanner;
    
    
    public class Payroll {
    
    	public static void main(String[] args) {
    		Scanner input = new Scanner ( System.in );
    		double hourlyRate;
    		double hoursWorked;
    		double grossPay; // Calculated weekly pay before taxes
    		double taxDeduction; // gross pay * 10%
    		double netPay; // Calculated weekly pay after taxes
    		
    		System.out.print("Employee First and Last name: ");
    		String employeeName = input.nextLine(); 
    
    		System.out.printf("Enter hourly rate for %s: $", employeeName);
    		hourlyRate = input.nextDouble(); 
    
    		while(hourlyRate < 0.00){ 
    		System.out.print("Please enter only a positive number: $");
    		hourlyRate = input.nextDouble();
    		}
    
    		System.out.printf("Number of hours %s worked this week: ", employeeName);
    		hoursWorked = input.nextDouble(); 
    
    		while (hoursWorked < 0.00){ 
    		System.out.print("Please enter only a positive number: ");
    		hoursWorked = input.nextDouble();
    		}
    
    		grossPay = hourlyRate * hoursWorked; 
    		System.out.printf("%s's total gross pay this week is: $%.2f\n", employeeName, grossPay); 
    		System.out.println();
    		
    		taxDeduction = grossPay * .10;
    		System.out.printf("%s's taxes taken out of his gross pay total: $%.2f\n", employeeName,taxDeduction); 
    		System.out.println();
    		
    		netPay = grossPay - taxDeduction;
    		System.out.printf("%s's total net pay this week is: $%.2f\n", employeeName,netPay); 
    		System.out.println();
    		
    
    		input.nextLine();
    		System.out.print("Employee name:"); // Loops back to start
    		employeeName = input.nextLine();
    
    		}
    		}
    I got the program done. Now I just dont know how to print the pay check for the net pay and a pay stub detailing the calculations. I would greatly appreciate it if someone could please help
    Last edited by bigley04; 12-01-2010 at 09:46 PM.

  5. #5
    bigley04 is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

    Default anyone know?

    does anybody know how to print a pay stub that would detail the calculations. Im stuck on it and have been working on it all day.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What exactly constitutes a "pay stub"?

    Also, this comment is not true:
    Java Code:
          System.out.print("Employee name:"); [color="red"][b]// Loops back to start[/b][/color]

  7. #7
    bigley04 is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

    Default

    essentially I just need to know how to print the calculations is all. In other words the person receiving the paycheck would need to know how their gross pay, net pay, etc were calculated

    ps I deleted that line of code already that has the wrong comments

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. payroll generation
    By kriti in forum New To Java
    Replies: 5
    Last Post: 06-02-2010, 04:21 PM
  2. Need help ASAP with Payroll Program Part 2
    By arrech326 in forum New To Java
    Replies: 10
    Last Post: 11-17-2009, 11:17 PM
  3. Payroll Project 1 Troubles
    By KiskaBaker in forum New To Java
    Replies: 3
    Last Post: 08-16-2009, 01:41 PM
  4. Payroll Program exits at wrong time
    By jsand2 in forum Java Applets
    Replies: 13
    Last Post: 01-26-2009, 04:10 AM
  5. Payroll Part 2, Java
    By lplopez92 in forum New To Java
    Replies: 2
    Last Post: 03-24-2008, 02:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •