Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

need help programming employee paycheck program


  • Please log in to reply

#1
isandozi

isandozi

    New Member

  • Member
  • Pip
  • 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.

please help me asap. i am using visual logic. thanks.
  • 0

Advertisements


#2
The Noodle

The Noodle

    Member

  • Member
  • PipPip
  • 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 :D
  • 0

#3
coyne20

coyne20

    Member

  • Member
  • PipPip
  • 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

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP