Results 1 to 8 of 8
Thread: Payroll program
- 12-01-2010, 05:15 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 4
- Rep Power
- 0
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.
-
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.
- 12-01-2010, 07:46 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 12-01-2010, 08:25 PM #4
Member
- Join Date
- Dec 2010
- Posts
- 4
- Rep Power
- 0
I got it
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 helpJava 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(); } }Last edited by bigley04; 12-01-2010 at 08:46 PM.
- 12-02-2010, 02:34 AM #5
Member
- Join Date
- Dec 2010
- Posts
- 4
- Rep Power
- 0
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.
-
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]
- 12-02-2010, 03:33 AM #7
Member
- Join Date
- Dec 2010
- Posts
- 4
- Rep Power
- 0
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
- 12-06-2010, 04:57 PM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Did you done all your calculation properly, first of all?
Similar Threads
-
payroll generation
By kriti in forum New To JavaReplies: 5Last Post: 06-02-2010, 03:21 PM -
Need help ASAP with Payroll Program Part 2
By arrech326 in forum New To JavaReplies: 10Last Post: 11-17-2009, 10:17 PM -
Payroll Project 1 Troubles
By KiskaBaker in forum New To JavaReplies: 3Last Post: 08-16-2009, 12:41 PM -
Payroll Program exits at wrong time
By jsand2 in forum Java AppletsReplies: 13Last Post: 01-26-2009, 03:10 AM -
Payroll Part 2, Java
By lplopez92 in forum New To JavaReplies: 2Last Post: 03-24-2008, 01:55 PM


LinkBack URL
About LinkBacks


Bookmarks