473,507 Members | 8,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need help writing a program that shows a pay for 3 shifts with deductions

1 New Member
Acme Parts runs a small factory and employs workers who are paid one of three hourly rates depending on their shift: first shift, $17 per hour; second shift, $18.50 per hour; third shift, $22 per hour. Each factory worker might work any number of hours per week; any hours greater than 40 are paid at one and one-half times the usual rate. In addition, second- and third-shift workers can elect to participate in the retirement plan for which 3% of the worker’s gross pay is deducted from the paychecks.

Write a program that prompts the user for hours worked, shift, and, if the shift is 2 or 3, whether the worker elects the retirement (1 for yes, 2 for no). Display:

Hours worked
Shift
Hourly pay rate
Regular pay
Overtime pay
Total of regular and overtime pay
Retirement deduction, if any
Net pay.

This is the program I have written so far:
import java.util.Scanner;
public class AcmePay
{
public static void print(double h, int s, double rate, double regularPay, double overtime, double total, int r, double gross)
{
System.out.print("\n");
System.out.println("****************************** *******");
System.out.println("****************************** *******");
System.out.println("Hours worked : "+ h);
System.out.println("Shift: " + s);
System.out.println("Hourly Pay Rate : $" + rate);
System.out.println("Regular Pay : $" + regularPay);
System.out.println("Overtime Pay : $" + overtime);
System.out.println("Total of regular and overTime pay : $" + total);
if(r == 1)
{
System.out.println("Retirment deduction " + (total - gross));
}

System.out.println("Net Pay: $"+ gross);
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Hours worked: ");
double hour = s.nextDouble();
System.out.print("Shift: ");
int shift = s.nextInt();
double pay;
double overpay = 0;
double totalPay ;
double hourRate;
int retire;
double netPay = 0;

if(shift == 1)
{
pay = 17 * hour;

if(hour>40)
{
overpay = ((hour - 40) * 25.5);
}

totalPay = pay + overpay;
hourRate = 17;
print(hour,shift,hourRate,pay,overpay,totalPay,0,t otalPay);
}
else if(shift ==2 || shift == 3)
{
System.out.print("Did you elect for retirement: ");
retire = s.nextInt();

if(shift == 2)
{
pay = (18.50 * hour);

if(hour>40)
{
overpay = ((hour - 40) * 27.75);
}

totalPay = pay + overpay;

if(retire==1)
{
netPay = totalPay - ((totalPay * 3)/100);
}
else{
netPay = totalPay;
}
hourRate = 18.50;

print(hour,shift,hourRate,pay,overpay,totalPay,ret ire,netPay);
}
else if(shift ==3)
{
pay = 22 * hour;

if(hour>40)
{
overpay = ((hour - 40) * 33);
}
totalPay = pay + overpay;

if(retire == 1)
{
netPay = totalPay - ((totalPay * 3)/100);
}
else
{
netPay = totalPay;
}

hourRate = 22;

print(hour,shift,hourRate,pay,overpay,totalPay,ret ire,netPay);
}

}
else
{
System.out.println("Invalid shift");
}

}
}
Oct 24 '18 #1
1 5306
chaarmann
785 Recognized Expert Contributor
Please use code tags to format the code so it is easier for us free helpers to read your program.

You mentioned that you need help, but you forgot to mention what problem you have.
So what is your program doing different as it's supposed to do? Where is the error message? Where are you stuck?
Apr 5 '19 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2240
by: Jim | last post by:
I am a FoxPro programmer. What software do I need to program using MS access... I have apps that are non-web standalone and some web based... Do you recommend any learning resources? ...
1
3446
by: cheche | last post by:
hi, help me!!! i need hashing program in C or in Java.. tnx, cheche
7
113182
by: habsy | last post by:
The below are the question given; Please help. (Payroll) Write a program that reads the following information and prints payroll statements in show message dialog box. These are the...
1
1598
by: ebook25 | last post by:
What i'm trying to do is writing Program that print the number of newlines,words and characters in counted file by python I'm lost and i do not how should i do it? that what i got so far ...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.