Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

need help programming employee paycheck program

#1 isandozi Posted 21 September 2010 - 10:22 PM

isandozi

New Member

• Member
• 2 posts
i need help with a program that determines an employees paycheck; i accept 3 inputs: name, hours worked, and pay rate.

after i take the inputs i need to determine the gross pay. and the amount of taxes. im having trouble with the taxes part. its kind of confusing

the requirements are:

the first 100 dollars are tax free

over 100 but less than 500, tax is 15 percent

over 500, tax is 28 percent plus 60 dollars

so if the gross pay is \$400, tax should be 45 dollars.

this is because the first 100 is tax free, then u have \$300 left over. and 15 percent of 300 is 45

thats how it works.

• 0

#2 The Noodle Posted 21 September 2010 - 11:55 PM

The Noodle

Member

• Member
• 82 posts
think of it in terms of tax brackets.

Bracket 1
max: 100
tax: 0

bracket 2
max 400
tax 15%

bracket 3
max: anything left
tax 28% + 60

so first see how much of the pay falls in the first bracket, then remove this from the pay to be taxed. Now check if the left over pay is < 400 if so then just find 15% and thats your tax. If the pay left is > 400 then take that 400 out of the pay and add 15% of 400 to a tax variable. Find 28% of any pay left and add that to the tax variable, then if you had any tax at 28% add 60 to the tax variable.

Thats one way of doing it, though because this sounds like assigned work you'll have to do the syntax yourself
• 0

#3 coyne20 Posted 08 October 2010 - 08:24 AM

coyne20

Member

• Member
• 35 posts
This program solves your problem below using Java:

package examples;

import java.util.Scanner;
import java.text.DecimalFormat;

public class TaxProgram
{
private int hours;
private String name;
private double hourlywage;

public int getHours() {
return hours;
}

public void setHours(int hours) {
this.hours = hours;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public double getHourlywage() {
return hourlywage;
}

public void setHourlywage(double hourlywage) {
this.hourlywage = hourlywage;
}

public double getNetPay(int hours, double hourlywage)
{

double grosspay = 0.0, netpay = 0.0;
grosspay = hours * hourlywage;

if(grosspay > 100 && grosspay < 500)
{
double tax = 0.15 * grosspay;
return netpay = grosspay - tax;
}

if(grosspay > 500)
{
double tax = (0.28 * grosspay) + 60;
return netpay = grosspay - tax;
}

return grosspay;
}

public static void main(String[] args)
{
DecimalFormat dp2 = new DecimalFormat("0.00");
TaxProgram tp = new TaxProgram();
Scanner sc = new Scanner(System.in);
System.out.println("Enter a name: ");
String name = sc.next();
tp.setName(name);
System.out.println("Enter the number of hours: ");
int hours = sc.nextInt();
tp.setHours(hours);
System.out.println("Enter the hourly wage: ");
double hourlywage = sc.nextDouble();
tp.setHourlywage(hourlywage);
System.out.println("The net pay for "+name+" is £"+dp2.format(tp.getNetPay(hours, hourlywage)));
}

}
• 0

Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users