Question

In: Computer Science

General Description: Write a program that processes weekly payroll for a small company. The program starts...

General Description: Write a program that processes weekly payroll for a small company. The program starts with printing a logo then asking for the total number of employees for the week. The program then inputs data for each individual employee and prints a paystub. At the end, it prints a report based on data for all employees.

Gross Pay: The company has two types of employees: Hourly and Salaried

- Hourly employees have an hourly wage, and are paid overtime (1.5 times the hourly wage) for any time worked over 40 hours. The program must ask for Hourly Rate and Number of hours worked, then calculates the Gross pay correctly.

- Salaried employees have a weekly Gross Salary, not based on the number of hours worked. So the program only asks for the Gross Salary.

Taxes: Taxes must be deducted from the paycheck of all employees, regardless of employee type:

- Federal Income Tax is a percentage of the Gross Pay. The Federal Tax Rate is determined as follows:

Gross Pay at least Gross Pay at most Federal Tax Rate 0.00 599.99 0% 600.00 799.00 4% 800.00 1099.99 8% 1100.00 Any above 1100 12%

- Social Security is 3% of Gross Pay.

- State Income Tax is 6% of any Gross Pay over $500 (so if Gross is $600 that’s 0.06% of (600-500) = $100, which is $6. For a Gross $500 and under, the tax is $0). In other words, “The first $500 is not taxed for anyone”

- Local Income Tax is 1.5% for local residents and 1% for non-residents.

Net Pay is the Gross minus the taxes deducted.

Report: The report includes the sum of each tax and the net pay for all employees, except that the amount for Social Security is double the total amount deducted from employees’ checks.

Bottom-Up Detailed Design:

AskEmplType(): Asks the user to enter the employee type (H,h,S,s), validating the input. Returns the value entered. GetHourlyGross(): Asks the user to enter the Hourly Rate and Hours worked. Calculates the gross, giving “time and a half” for any hours over 40. Returns the gross calculated. (Ex: rate=25, hours=45: gross = (40 +( (45-40) x1.5)) x 25

AskResident(): Asks the user if the employee is a local resident (Y,y,N,n), validating the input. Returns the answer.

CalcFedTax(): Given the gross, calculates and returns the amount of federal tax.

CalcStateTax(): Given the gross, calculates and returns the amount of state tax.

CalcLocalTax(): Given the gross and the resident status (Y/y/N/n), calculates and returns the amount of local tax.

PrintStub(): Given the first and last name, gross, taxes and net, prints the payroll stub for the employee (should do NO calculations nor “ask the user”, just prints. Exception: it may calculate the TOTAL TAX by adding up the tax numbers given; or better, calculate it in ProcessEmployee() and pass it intoPrintStub() as another argument).

ProcessEmployee: Given the employee number, and invoking the sub functions indicated, does all processing for the employee. Returns the first name, last name, gross, net pay, fed tax, ssi tax, state tax and local tax of the employee processed. Note: functions are not defined for some operations of processing an employee (ex: Enter names, enter weekly salary for a salaried employee). The designers deemed these activities to be too trivial to be their own function. Therefore, it is the job of ProcessEmployee() to carry out these minor tasks, in addition to coordinating/invoking the sub-functions.

PrintLogo(): just prints the logo

AskNumEmployees(): Asks the user to enter the number of employees to process, validating the number as 1 or more. Returns the number entered.

UpdateTotals(): Given the gross, net pay, fed tax, ssi tax, state tax and local tax of the last employee processed, adds these numbers to the totals for all employees. Returns the updated totals.

PrintReport(): given the totals for gross, net pay, fed tax, ssi tax, state tax and local tax of all employees processed, prints the report as shown above. Note that the amount of ssi tax printed is two times the given amount.

Main(): invokes the functions indicated as needed to control the entire payroll program. Should do a system pause at the very end.

Solutions

Expert Solution

import java.util.Scanner;

class payroll {
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);

System.out.println("Enter employee's name:");
String employee = input.next();

System.out.println("Enter number of hours worked:");
double hours = input.nextDouble();

System.out.println("Enter hourly pay rate:");
double pay = input.nextDouble();

double gross_pay = pay * hours;

System.out.println("Enter federal tax withholding rate:");
double fedtax = input.nextDouble();
double fedtaxr = fedtax * 0.20;

System.out.println("Enter state tax withholding rate:");
double statetax = input.nextDouble();

double statetaxr = statetax * 0.20;

double deductions = fedtaxr + statetaxr;

double total_pay = gross_pay - deductions;

System.out.println("Employee name: " + employee);

System.out.println("Hours worked: " + hours);

System.out.println(" Enter payrate: " + pay);

System.out.println(" Enter gross pay: " + gross_pay);

System.out.println(" Deductions: ");
System.out.println("\t Federdal Withholding (20.0%): " + fedtaxr);
System.out.println("\t State Withholding (9.0%)" + statetaxr);
System.out.println("\t Total deductions:" + deductions);
System.out.println("Total pay: " + total_pay);
}
}
Apr 17 '10 #1
Post Reply
Share this Question
Share on Google+
7 Replies
Dheeraj Joshi
Expert 100+
P: 1,123
Dheeraj Joshi
What errors you are getting?

Regards
Dheeraj Joshi
Apr 19 '10 #2
reply
P: 2
Swaran
Here's the program in Java.....

Expand|Select|Wrap|Line Numbers
// @Copyright: Swaran Bindra


public class PayrollCalc
{
private String name;
private double hoursWorked;
private double hourlyPayRate;
private static final double FEDERAL_TAX_WITHHOLDING_RATE = 0.20;
private static final double STATE_TAX_WITHHOLDING_RATE = 0.09;


public PayrollCalc()
{

}

public PayrollCalc(String n, double hw, double hpr)
{
this.name = n;
this.hoursWorked = hw;
this.hourlyPayRate = hpr;
}

public double grossPay(double hourlyRate, double hrsWorked)
{
double grossPay = (hourlyRate * hrsWorked);
return grossPay;
}


Related Solutions

Write a program that displays a weekly payroll report. A loop in the program should ask...
Write a program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay. Input Validation: Do not accept negative numbers for any of the items entered. Do not...
In C Programming Create a payroll program to store and calculate the payroll for a small...
In C Programming Create a payroll program to store and calculate the payroll for a small company as follows: Ask the user for the number of employees and only accept the number if it is between 5 and 40 employees, otherwise prompt the user again and test the input, keep repeating until the user enters an acceptable number. Create an array of floats that is 4 rows and an number of columns equal to the number of employees in the...
Write Program in C: Write a program that: program starts; declares and initializes to 7.25% constant...
Write Program in C: Write a program that: program starts; declares and initializes to 7.25% constant float variable NJSALES_TAX; declares and initializes to 1000 an integer variable total; declares and initializes to zero a float variable grand_total; prompt and input on new line total; calculate grand_total to equal total plus (total*NJSALES_TAX); if grand_total <= 1000 print on new line “Grand total is less than or equal to 1000 it is $” and the grand_total to two decimal places; else if...
Using Java, The program you will be writing displays a weekly payroll report. A loop in...
Using Java, The program you will be writing displays a weekly payroll report. A loop in the program should ask the user for the employee’s number, employee’s last name, number of hours worked, hourly pay rate, state tax, and federal tax rate. After the data is entered and the user hits the enter key, the program will calculate gross and net pay then displays employee’s payroll information as follows and asks for the next employees’ information. if the user works...
Boxcom Company had a total bi-weekly payroll of $ 90,000. The entire payroll was subject to...
Boxcom Company had a total bi-weekly payroll of $ 90,000. The entire payroll was subject to CPP (4.95%), EI (1.66%), and income tax withholdings of $ 11,880. Union dues of $ 1,125 and Health insurance premiums of $ 2,850 were also withheld. Boxcom will match employee CPP and 1.4 times employees EI Instructions                                             Prepare the journal entries to record the employee wages/salaries and payroll deductions Prepare the journal entries to record the employer payroll contributions    Prepare the journal entries to...
The following is the description of the payroll system of a manufacturing company:
The following is the description of the payroll system of a manufacturing company:Employees of the company use a time clock in an unsupervised area to record their time on the job.The site supervisor tries to monitor the recording process. However, due to other duties, thesupervisor is often distracted. The site supervisor collects the time cards from employees every Friday.The supervisor then reviews and approves the time cards and send them to payroll clerk.The payroll clerk uses a stand-alone workstation to...
The following is the description of the payroll system of a manufacturing company: Employees of the...
The following is the description of the payroll system of a manufacturing company: Employees of the company use a time clock in an unsupervised area to record their time on the job. The site supervisor tries to monitor the recording process. However, due to other duties, the supervisor is often distracted. The site supervisor collects the time cards from employees every Friday. The supervisor then reviews and approves the time cards and send them to payroll clerk. The payroll clerk...
The following is the description of the payroll system of a manufacturing company: Employees of the...
The following is the description of the payroll system of a manufacturing company: Employees of the company use a time clock in an unsupervised area to record their time on the job. The site supervisor tries to monitor the recording process. However, due to other duties, the supervisor is often distracted. The site supervisor collects the time cards from employees every Friday. The supervisor then reviews and approves the time cards and send them to payroll clerk. The payroll clerk...
The following is the description of the payroll system of a manufacturing company: Employees of the...
The following is the description of the payroll system of a manufacturing company: Employees of the company use a time clock in an unsupervised area to record their time on the job. The site supervisor tries to monitor the recording process. However, due to other duties, the supervisor is often distracted. The site supervisor collects the time cards from employees every Friday. The supervisor then reviews and approves the time cards and send them to payroll clerk. The payroll clerk...
TITLE Updating Accounts Using Doubly Linked List TOPICS Doubly Linked List DESCRIPTION General Write a program...
TITLE Updating Accounts Using Doubly Linked List TOPICS Doubly Linked List DESCRIPTION General Write a program that will update bank accounts stored in a master file using updates from a transaction file. The program will maintain accounts using a doubly linked list. The input data will consist of two text files: a master file and a transaction file. See data in Test section below.  The master file will contain only the current account data. For each account, it will contain account...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT