Help Needed

• February 13th, 2013, 02:48 AM
komal510
Help Needed
IF Statements

Write the program logic that will compute the paycheck of an employee. This is as much an exercise in designing your logic as much as a programming exercise in the grammar and syntax.

Your program's logic will perform a user to perform the following:
1. Enter the employee's LAST Name
2. Enter the employee's FIRST Name
3. Enter the employee's ID Number
4. Enter the employee's Total Hours Worked up to a maximum of 60 hours
5. Enter the employee's Pay Per Hour. The Pay per hour cannot be more than \$100.00 per hour. It cannot be less than the minimum wage (i.e. \$8.50 per hour). Detect any erroneous pay rate and set it to a default. If less than the minimum hourly wage, set to the minimum hourly wage. If greater than the maximum rate then set that employee to the maximum rate. Display an appropriate “error message” telling that data entry clerk what they did.
6. Federal tax rate and State tax rate range from zero to 40%. State and Federal tax rates cannot exceed a combined 80%.
7. Calculations include:
a) Compute the Regular Pay (any hours up to 40 hours) Regular Hours X Pay Per Hour
b) Compute the Overtime Pay if ANY (hours OVER 40 hours)
Overtime Hours X Pay Per Hour X 1.25 ("time and a quarter" for overtime)
c) Compute Gross Pay
Regular Pay + Overtime Pay (if NO overtime then Overtime Pay is zero)
d) Compute Federal Taxes Withheld (assume 20% rate, i.e. 0.2) Gross Pay X Federal Tax Rate
e) Compute State Taxes Withheld (assume 5% rate, i.e. 0.05) Gross Pay X State Tax Rate
f) Compute Net Pay (Gross Pay - Federal Taxes Withheld - State Taxes Withheld)

Output the employee's LAST Name, FIRST Name, ID Number, Total Hours, Regular Hours, Overtime Hours, if any (if NO overtime hours then don't print it), Gross Pay, Regular Pay, Overtime Pay, if any (if NO overtime hours then don't print it), Federal Taxes Withheld, State Taxes Withheld, Net Pay. Output format, I leave to your imagination (i.e. some sort of if statement?).

output where i have to show last name , first name , id, total hours, regular hours
then regular hour and over time
then gross pay then federal tax and state tax . i need the constant declare
• February 13th, 2013, 06:16 AM
Norm
Re: Help Needed

What have you tried?
• February 13th, 2013, 12:38 PM
komal510
Re: Help Needed
// Assignment 2
import java.io.*;

public class payment
{
public static void main(String args[]) throws IOException
{
System.out.println("Enter your total work hrs: ");
if( hr > 60)
{
System.out.println("Total Hours can not be more than 60hrs");
System.out.println("Enter your total work hrs: ");
}
System.out.println("Enter pay per hrs rate: ");
if(rate>100)
{
System.out.println("Rate per hr. not correct");
rate = 100.00;
}
if(rate<8.5)
{
System.out.println("Rate per hr. not correct");
rate = 8.5;
}
System.out.println("Enter Federal tax(0% - 40%): ");
System.out.println("Enter State tax (0% - 40%): ");
if((fd+st)>80)
System.out.println("Wrong tax rate enterd");
Double rpay; Double otime=0.0;
if(hr<=40)
rpay=hr*rate;
else
{
rpay= 40*rate; otime= (hr-40) * rate * 1.25;
}

Double totalworkhours = hr+otime;
Double gpay= rpay+otime;
Double ftw= gpay*fd/100;
Double stw=gpay*st/100;
Double netpay= gpay-ftw-stw;

System.out.println("Last Name"+ last +"First Name"+ first);
System.out.println("ID number: "+ ID);
System.out.println("Total Hours Worked " + totalworkhours);
System.out.println("Regular time: "+ (hr-otime));
System.out.println("Over Time: "+ otime);
System.out.println(" Federal tax: "+ ftw);
System.out.println(" State tax : "+ stw);
System.out.println("Net Pay: "+ netpay);

}
}
this is code but its not working
• February 13th, 2013, 12:41 PM
Norm
Re: Help Needed
Quote:

its not working
If there are error messages, please copy the full text and paste it here.
If the output is wrong, copy the output and paste it here and add some comments saying what is wrong with the output and show what the output should be.

[code=java]
[/code]
to get highlighting and preserve formatting.
• February 13th, 2013, 12:46 PM
komal510
Re: Help Needed
Last Name johalFirst Name navi
ID number: 123de
Total Hours Worked 636.0
Regular time: -524.0
Over Time: 580.0
Federal tax: 348.0
State tax : 174.0
Net Pay: 1218.0
like when more than 40 then it gaves me a negative answer for the regular time how can i fix it
• February 13th, 2013, 12:55 PM
Norm
Re: Help Needed
Quote:

Regular time: "+ (hr-otime));
What are the expected and actual values of hr and otime?
If otime > hr, then the result will be a negative number.

Look at where each of those variables get their values and see why they are a problem.

Define what is in the hr variable
and in the otime variable.
Are they compatible?

Quote:

when more than 40 then it gaves me a negative answer for the regular time